Node Package Manager Cheat Sheet

A Programming › node.js cheat sheet in English by GregFinzer

Quick Reference for NPM

32,400 views 9,116 downloads 4 Apr 2017 History
3.7 avg · 2 ratings

Install Packages

Install a package and the update packag­e.json with the package name and version
npm install <pa­ckage name> --save
Install Latest Version of a Package do not update packag­e.json
npm install <pa­ckage name>
Install Specific Package Version
npm install <pa­cka­ge-­nam­e>@­<ve­rsi­on-­num­ber>
Install a scoped package
npm install @<n­ame­spa­ce>­/<p­ack­age­-na­me>
Install to dev depend­encies
npm install <pa­cka­ge-­nam­e> --save-dev
Install package globally
npm install <pa­cka­ge-­nam­e> -g
Install from GitHub
npm install <Gi­tHu­b-U­RL>
Install from a folder (for private packages)
npm install <pa­th>
Restore packages defined in packag­e.json
npm install
Find the Global Install Directory
npm config get prefix

Uninstall Packages

Uninstall and remove from packag­e.json
npm uninstall <pa­cka­ge-­nam­e> --save
Uninstall Package
npm uninstall <pa­cka­ge-­nam­e>
Uninstall Global Package
npm uninstall -g <pa­cka­ge-­nam­e>
Remove extraneous (unused) packages
npm prune
Clear from the NPM Cache
npm cache clean

List Packages

List packages used by your applic­ation no depend­encies
npm ls --depth 0
List packages used by your applic­ation with depend­encies
npm ls
List packages installed globally no depend­encies
npm ls -g --depth 0
List packages and depend­encies installed globally
npm ls -g true
List dev depend­encies
npm ls --dev true
List prod depend­encies
npm ls --prod true
Show the latest version of a package on npm
npm view <pa­cka­ge-­nam­e> version
Show current version of a local npm package
npm show <pa­cka­ge-­nam­e> version

Help

Get general help
npm -h
Get help about a command
npm <co­mma­nd-­nam­e> -h
Go to help page about command
npm help <co­mma­nd-­nam­e>
Go to the repository for the page
npm repo <pa­cka­ge-­nam­e>

Badges

Useful Cheat Sheet Nice Cheat Sheet Good Cheat Sheet Downloaded from Unusual Locations × 6

Comments (1)

bledix 10:12 1 Oct 2018

thanks

Reply

Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.