Why do I need to split between dev and prod dependencies?

Asked 6 months ago

I'm trying to understand the difference between dev and peerdependencies in a npm package.json file. Can someone explain what the difference is and when you would use each one?

Omar Christensen

Thursday, June 16, 2022

In a nutshell, devDependencies are for things used in the development environment, such as unit tests and build tools, while peerDependencies are for libraries that your package depends on but which are intended to be provided by the consumer of your package. For example, say you were developing a package that uses Lodash. You would list Lodash as a peerDependency in your package.json file because it's something that your package needs in order to work, but which isn't something you need to develop or build your package. On the other hand, if you were using Babel to compile your code, you would list it as a devDependency because you need it during the development process but the consumer of your package doesn't need it.





Write an answer...

Cancel

Please follow our  Community Guidelines

Can't find what you're looking for?