How do you prevent install of "devDependencies" NPM modules for Node.js (package.json)?

The npm install command will install the devDependencies along other dependencies when run inside a package directory, in a development environment (the default).

Use npm install --only=prod (or --only=production) to install only dependencies, and not devDependencies,regardless of the value of the NODE_ENV environment variable.

Source: npm docs

Note: Before v3.3.0 of npm (2015-08-13), the option was called --production, i.e. npm install --production.


I run into that problem too! npm install is somewhat confusing and web posts keep bringing in the -d/--dev flags as if there is an explicit 'development' install mode.

  • npm install will install both "dependencies" and "devDependencies"

  • npm install --production will only install "dependencies"

  • npm install --dev will only install "devDependencies"


The new option is:

npm install --only=prod

If you want to install only devDependencies:

npm install --only=dev

Tags:

Node.Js

Npm