npm - Notes

dependencies vs. development dependencies

install package as dependency:

$ npm install --save <package>

install package as development dependency:

$ npm install --save-dev <package>


development dependencies:

peer dependencies


peer dependencies tell npm:

I need this package, but I need the version that is part of the project, not some version private to my module.

By adding a package in peerDependencies you are saying:

  • My code is compatible with this version of the package.
  • If this package already exists in node_modules, do nothing.
  • If this package doesn’t already exist in the node_modules directory or it is the wrong version, don’t add it. But, show a warning to the user that it wasn’t found.

don’t use peer dependencies if you are not npm package author - they are not automatically installed by npm (since version 3):

peer dependencies are not automatically installed unless a dependent package explicitly depends on the peer package itself