Jump to navigation

npm commands

Change Node version

npm install -g n   # Install n globally
n 0.10.33          # Install and use v0.10.33

Get help

npm help

// Get help on specific command
npm install -h

View latest version of npm

npm -v

Install a package

npm install PACKAGENAME

// Install globally, might need global permissions
npm install PACKAGENAME -g

// Install as a dependency, adds to package.json
npm install PACKAGENAME --save

// Install packages defined in package.json
npm install

Uninstall a package

npm uninstall PACKAGENAME

// Removes from package.json too
npm uninstall PACKAGENAME --save

// Remove globally
npm uninstall PACKAGENAME -g

Gives overview of package versions

npm outdated

Update packages, if no package.json file is present it will update all packages in node_modules folder to the latest version. This doesn't seem to update the package.json file, however I found a package that does the job npm-check-updates.

npm update


npm faq