What’s the difference between dependencies, devDependencies and peerDependencies in npm package.json file?

Technology CommunityCategory: Node.jsWhat’s the difference between dependencies, devDependencies and peerDependencies in npm package.json file?
VietMX Staff asked 3 years ago
  • dependencies – Dependencies that your project needs to run, like a library that provides functions that you call from your code. They are installed transitively (if A depends on B depends on C, npm install on A will install B and C).
  • devDependencies – Dependencies you only need during development or releasing, like compilers that take your code and compile it into javascript, test frameworks or documentation generators. They are not installed transitively (if A depends on B dev-depends on C, npm install on A will install B only).
  • peerDependencies – Dependencies that your project hooks into, or modifies, in the parent project, usually a plugin for some other library or tool. It is just intended to be a check, making sure that the parent project (project that will depend on your project) has a dependency on the project you hook into. So if you make a plugin C that adds functionality to library B, then someone making a project A will need to have a dependency on B if they have a dependency on C. They are not installed (unless npm < 3), they are only checked for.