(Full description and list of commands at - https://npmjs.org/doc/index.html)
Make sure to export your local $PATH and prepand relative ./node_modules/.bin/:
export PATH="$PATH:./node_modules/.bin"
This will allow executing npm binaries installed into the .bin local and isolated current ./node_modules
npm install <module-name> --save
Install a package and also update package.json with the installed version and package name, but into the devDependencies section.
npm install <module-name> --save-dev
npm config set save true
npm init
npm config ls -l
npm install git://github.com/substack/node-browserify.git
npm update npm -g
npm docs <module-name>
"scripts" : {"test" : "node testfile.js"}
npm test
Uninstall package (A nice thing about npm is you can always just rm -rf ./node_modules/<module_name>
).
npm uninstall <module_name>
npm edit <module_name>
npm config set editor "sublime"
npm publish --tag beta
npm install --dry-run
npm outdated
npm shrinkwrap
npm install git://github.com/Marak/colors.js#v0.6.0
npm xmas
npm visnup
npm substack
Here are some of my favourites:
Update all to the latest version of all dependencies according to the version range in package.json (
npm install
does not check for newer versions when the version in node_modules is within the version range):Link to the source-code for a dependency to test changes locally before publishing new versions:
To set default values for
npm init
:To set project-specific config. I.e. publish to a private repo. Create a
.npmrc
file in the project folder:By default npm uses
.gitignore
to ignore files to include in the published package. If you need a different set of ignores, use.npmignore
as well.Not part of the
npm
cli, but I find npm-check a lot easier thannpm outdated
. Instead of only listing the outdated depenencies, it can print out commands to copy-paste to update each outdated dependency, or use the interactive mode where you just mark the dependencies to update.