NPMmmm #1: Dev Dependencies, Dependencies

Dylan Avery
Apr 12, 2017 · 1 min read

What is the difference between save and save-dev?

Today we are going to go over something i’ve wanted to clarify for awhile, the difference between devDependencies and dependencies.

When using NPM, the first thing to do is annpm init, which will set up a package.json file for us based off our answers to its survey. This package.json describes our module, and in it we can see a list of all installed dependencies and devDependencies that we have installed and added to our project.

The difference between these two, is that devDependencies are modules which are only required during development, while dependencies are modules which are also required at runtime.

To save a dependency as a devDependency on installation we need to do an npm install --save-dev, instead of just an npm install --save. A nice shorthand for installing a devDependency that I like to use is npm i -D. The shorthand for saving a regular dependency is -S instead of -D.

Some good examples of dependencies which would be required at runtime include React, Redux, Express, and Axios.

Some good examples of when to install devDependencies would be Nodemon, Babel, ESLint, and testing frameworks like Chai, Mocha, Enzyme, etc…

Next time, we will dig deeper into our package.json filer. Stay tuned for NPMmmm #2: Package.json, coming soon!

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store