npm - Notes


dependencies vs. development dependencies

install package as dependency:

$ npm install --save <package>

install package as development dependency:

$ npm install --save-dev <package>

dependencies:

development dependencies:

peer dependencies

  1. https://lexi-lambda.github.io/blog/2016/08/24/understanding-the-npm-dependency-model/
  2. https://stackoverflow.com/a/34645112/3632318
  3. https://blog.angularindepth.com/npm-peer-dependencies-f843f3ac4e7f

https://stackoverflow.com/a/34645112/3632318

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.

https://blog.angularindepth.com/npm-peer-dependencies-f843f3ac4e7f

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):

https://lexi-lambda.github.io/blog/2016/08/24/understanding-the-npm-dependency-model/

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