Skip to content

Instantly share code, notes, and snippets.

@codayon
Last active August 1, 2025 16:25
Show Gist options
  • Save codayon/f58efa9785a1966e029ed33155c47a7a to your computer and use it in GitHub Desktop.
Save codayon/f58efa9785a1966e029ed33155c47a7a to your computer and use it in GitHub Desktop.

NPM Essentials

Install Package

npm i <pkg>
# example
npm i lodash

Install Globally

npm i -g <pkg>
# example
npm i -g nodemon

Install Production

npm i --production

Install Dev Dependency

npm i --save-dev <pkg>
# example
npm i --save-dev jest

Install Exact Version

npm i --save-exact <pkg>
# example
npm i --save-exact lodash

Show Dependency Tree

npm ls

List Global Packages

npm ls -g --depth 0

List Outdated Packages

npm outdated

Detailed Outdated List

npm outdated --long

Update Production Packages

npm update

Update Dev Packages

npm update --dev

Update Global Packages

npm update -g

Update Specific Package

npm update <pkg>
# example
npm update lodash

Remove Package

npm rm <pkg>
# example
npm rm lodash

Remove Dev Dependency

npm rm --save-dev <pkg>
# example
npm rm --save-dev jest

Initialize Project

npm init

Run Script

npm run <script_name>
# example
npm run start

Check Vulnerabilities

npm audit

Fix Vulnerabilities

npm audit fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment