Node.js — npm Commands
npm is the package manager for JavaScript.
Resources
Requirements
Install Node.js on your machine.
Creating apackage.json
file
npm init
— createpackage.json
file initating a command line questionnaire
npm init --yes
ornpm init -y
— create apackage.json
file and fill in default values
Managing global packages
npm ls -g --depth=0
— list out global installed packages
npm uninstall -g [<name> [<name ...]]
uninstall global package(s)
npm outdated --global
— check for outdated global installed packages
Managing project packages
npm list
ornpm ls
(preferred shorthand) — list out currently installed npm packages
npm ls --depth=0
— only draws out the top of the dependency tree
npm install
— will install both "dependencies" and "devDependencies"
npm install --production
— will only install "dependencies"
npm install --dev
— will only install "devDependencies"
npm outdated
— check for outdated packages
npm prune [<name> [<name ...]]
— removes "extraneous" packages
npm where
— show npm installed path
npm cache clean
— clean npm cache
npm run-script <script-name>
or for shortnpm run <script-name>
- run scripts frompackage.json