NPM: devDependencies vs dependencies in package.json

Sumant Mishra
2 min readJul 5, 2019

In a Node JS application, package.json is very important as it contains all metadata information about that Project or application. This is a plain JSON(Java Script Object Notation) text file which contains various useful properties required for application setup.

Out of several other properties in package.json, dependencies and devDependencies are two important properties. Here we will discuss use of both dependencies and devDependencies and the difference between these two.

Both dependencies and devDependencies are two plain JSON objects in package.json. Both contain the names and versions of the dependent node modules (NPM packages) required for the application development. But the difference between these two properties are:

devDependencies: This property contains the names and versions of the node modules which are required only for development purposes like ESLint, JEST, babel etc.

To install a node module as devDependency:

npm install --save-dev [npm package name]

or in short form

npm i -D [npm package name]

Any of the above command will add the package name and its version to devDependencies section of package.json.

dependencies: This property contains the names and versions of the node modules which are also required at runtime. These modules will also be downloaded as dependent package if the application is published as NPM package and used as npm install [package name].

To install a node module as dependency:

npm install --save [npm package name]

or in short form

npm i -S [npm package name]

Any of the above command will add the package name and its version to dependencies section of package.json.

Sample JSON structure for devDependencies and dependencies:

Below JSON structure shows the dependencies and devDependencies for a simple react-redux application:

--

--

Sumant Mishra
Sumant Mishra

Written by Sumant Mishra

Fullstack Architect || TOGAF 9 || AWSCSAA || Cloud Practitioner || NodeJS || React & Angular || Docker || Coder

No responses yet