# npm dependencies and devDependencies

> Learn the difference between npm dependencies and devDependencies, how the -D flag adds dev-only packages, and how --production skips them on deploy.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2018-08-17 | Topics: [Node.js](https://flaviocopes.com/tags/node/) | Canonical: https://flaviocopes.com/npm-dependencies-devdependencies/

When you install an [npm](https://flaviocopes.com/npm/) package using `npm install <package-name>`, you are installing it as a **dependency**.

The package is automatically listed in the [package.json file](https://flaviocopes.com/package-json/), under the `dependencies` list (as of npm 5: before you had to manually specify `--save`).

When you add the `-D` flag, or `--save-dev`, you are installing it as a development dependency, which adds it to the `devDependencies` list.

Development dependencies are intended as development-only packages, that are unneeded in production. For example testing packages, [webpack](https://flaviocopes.com/webpack/) or [Babel](https://flaviocopes.com/babel/).

When you go in production, if you type `npm install` and the folder contains a `package.json` file, they are installed, as npm assumes this is a development deploy.

You need to set the `--production` flag (`npm install --production`) to avoid installing those development dependencies.
