Skip to content

Instantly share code, notes, and snippets.

@nicolashery
Created May 16, 2015 15:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicolashery/2d259b6ccca28020533c to your computer and use it in GitHub Desktop.
Save nicolashery/2d259b6ccca28020533c to your computer and use it in GitHub Desktop.
npm cheat sheet
# avoid "works on my machine" by always locking dependency versions
npm config set save-exact=true
# install/uninstall project packages with flags that will update package.json
npm install --save lodash
npm install --save-dev jshint
npm uninstall --save lodash
# tool that makes upgrading dependencies easier, install it globally
npm install -g david
# in a project directory, run:
david
# it will give give you commands you can copy/paste to update dependencies
# sometimes updating doesn't grab latest version
# instead of using:
npm update -g david
# use this:
npm install -g david@latest
# when working on 2 repos, one depending on the other
cd /code/my-dep
npm link
cd /code/my-app
npm link my-dep
# asumes "my-dep" is also name in package.json, which is what npm link needs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment