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).

In version 8.x and above use --omit=dev flag to install only regular dependencies:

npm install --omit=dev

This will install only dependencies, and not devDependencies, regardless of the value of the NODE_ENV environment variable.

If you use 6.x or an earlier version, you need to use the --only=prod flag instead.

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

npm install --production

You may also need --no-optional flag.

Leave a Comment