npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

npm install --save-dev doesn't install package at all

Today, all of a sudden, installing a package as dev dependency (e.g. npm i -D react) doesn’t install it into node_modules, and only adds it to devDependencies in package.json.

Then, I have to do npm i --only=dev for npm to actually install the package.

On top of it, if the package is already installed as devDep, installing a different version using npm i -D package@version displays a message that the package is up to date, and I have to install the different version as a non-dev dependency again.

Also, doing a clean install/update via npm install only installs non-dev dependencies, and again I have to do an extra npm i --only=dev to get the dev deps.

Any idea what’s going on?

What I’ve tried:

What I’m currently running:

Thanks for help.


It sounds like you might have NODE_ENV set to “production”, but that only explains the clean install without arguments: https://docs.npmjs.com/cli/install

With the --production flag (or when the NODE_ENV environment variable is set to production), npm will not install modules listed in devDependencies.

NOTE: The --production flag has no particular meaning when adding a dependency to a project.


Mhm, now that’s embarrassing. I did a have NODE_ENV set to production. I not only missed that, but also the mention in the docs :blush:.

Turns out, in windows, removing an env variable is not simple. You need to run:

reg delete "HKCU\Environment" /v NODE_ENV /f

and reboot (or similar).

It fixed all the issues.

The mention of

NOTE: The --production flag has no particular meaning when adding a dependency to a project.

likely doesn’t relate to NODE_ENV, and thus affects even npm i -D installs.

Thanks for your help, who knows how long it’d take for me to notice the env var :).