npm dependencies and devDependencies

When is a package a dependency and when is a dev dependency?

When you install the npm package usingnpm install <package-name>, You are installing it asrely.

The package will automatically be listed inpackage.json file, underdependenciesList (from npm 5: before you have to specify manually--save).

When you add-DMark, or--save-dev, You install it as a development dependency and add it todevDependenciesList.

The development dependency is intended to be used as a development-only package and is not required in production. For example, the test package,Web packageorTower of Babel.

When you go into production, if you typenpm installAnd the folder contains apackage.jsonFiles, they are installed, because npm assumes this is a development deployment.

You need to set--productionbanner(npm install --production) To avoid installing these development dependencies.

Download mine for freeNode.js manual


More node tutorials: