Difference between dependencies, dev dependencies, and peer dependencies

Difference between dependencies, dev dependencies, and peer dependencies

Today we’ll learn the difference between dependencies, dev dependencies, and peer dependencies.

As we know npm is the world’s largest Software Registry and all npm packages are defined in files called package.json.

Let’s understand the difference between dependencies, dev dependencies, and peer dependencies.

Dependencies:

In package.json, you’ll see an object called dependencies. It contains all the dependencies that are required by your application, and your application will not be run.

these dependencies are required in production.

examples: React, Redux, Express, Material-UI

Here you’ll see the react as a dependencies which means our project requires the react to run.

DevDependencies

Those dependencies that are only required in development, not in production

For example jest we required jest only in development to test out apps, not in production,

Other examples: Eslint, Babel, our app can run without these dependencies these are not required in production

Here you’ll see the jest, eslint, as a devDependencies which means our project does not require the react to run.

PeerDependencies

These are used to specify that our package is compatible with a specific version of an npm package

example: React, Angular

We can’t install dependencies as peer-dependencies as for now, we have to install them and manually move them to peerDependencies object in package.json

Here you’ll see react, as inpeerDependencies which means our project is compatible with this version of react.

Hope you like it 🤗

Happy coding!

want to give suggestions:-

find me on LinkedIn Twitter

have a look at my portfolio

Email me at nidhisharma639593@gmail.com