devDependencies not installing with npm install command

I’m having trouble on my Windows machine where running npm install only installs the regular dependencies but skips all the devDependencies. This seems weird because I thought npm install should install everything by default.

The only way I can get devDependencies to install is by running npm install --dev specifically. But this doesn’t seem right to me.

I’m wondering if there’s something wrong with my package.json file or if there’s a setting I’m missing. Here’s my package.json:

{
  "name": "my-project",
  "version": "1.0.0",
  "private": true,
  "devDependencies": {
    "webpack": "^4.0.0",
    "babel-loader": "^8.0.0",
    "css-loader": "^3.0.0",
    "node-sass": "^4.0.0",
    "terser-webpack-plugin": "^2.0.0"
  },
  "dependencies": {
    "lodash": "^4.0.0"
  }
}

What could be causing this issue and how do I fix it so that npm install works normally?

Had this exact problem a few months back on my Windows dev machine. Turns out I’d accidentally run npm config set production true during another project setup and completely forgot about it. This setting sticks globally across all your npm projects until you explicitly remove it. Run npm config get production to see if it returns true - if it does, that’s your culprit. Use npm config delete production to remove it entirely. Also check if you’re inside a CI environment or have any npm scripts that might be setting production mode. The --dev flag working confirms npm is treating your environment as production when it shouldn’t be.

This usually means npm thinks it’s in production mode. Check if NODE_ENV is set to ‘production’ - that’s why it’s skipping devDependencies. Run echo $NODE_ENV to see what it’s set to. If it shows ‘production’, npm won’t install dev dependencies by default. You might also have the --production flag stuck in your npm config. Run npm config list to check. To fix it, either unset NODE_ENV or force dev dependencies with npm install --include=dev. Your package.json is fine - this is definitely an environment issue, not a config problem.

try clearing your npm cache with npm cache clean --force then check for any .npmrc files in your project. they might have production flags set. also, run npm config delete production, especially on windows where configs can act up sometimes.