Skip to content

Instantly share code, notes, and snippets.

@remarkablemark
Last active June 21, 2016 15:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save remarkablemark/0b58fa9ac332f7558bd87c7d502fc6ef to your computer and use it in GitHub Desktop.
Save remarkablemark/0b58fa9ac332f7558bd87c7d502fc6ef to your computer and use it in GitHub Desktop.
npm resources

useful npm commands

Create a package.json:

npm init -y # use defaults without prompting for options

View registry info:

npm view <package-name>

Install a package:

npm install <package-name>
npm install -g <package-name> # install a package globally
npm install --save <package-name> # package will appear in dependencies
npm install --save-dev <package-name> # package will appear in devDependencies
npm --cache-min 9999999 install <package.name> # install package from the cache
npm install <folder> # install a package that is sitting in a folder on the filesystem

List installed packages:

npm ls --depth=0
npm ls --depth=0 -g # list globally installed packages

Rebuild a package:

npm rebuild # useful when all your C++ addons must be recompiled when switching node versions

Remove extraneous packages:

npm prune # remove extraneous package(s) not listed in package.json

Lock down dependency versions:

npm shrinkwrap
npm install --save --save-exact <package-name>

Run package scripts:

npm run # list all run scripts
npm run <script-name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment