[node.js] npm install won't install devDependencies

On windows for some reason when I run npm install it won't install devDependencies. AFAIK it should. If I run npm install --dev devDependencies are installed. I don't understand why npm install doesn't install devDependencies too, but installs only dependencies. What could be the reason? How can I fix it?

Maybe something is wrong with my package.json? It is listed below if it may be helpful:

{
  "name": "try-brunch",
  "version": "0.1.0",
  "private": "true",
  "devDependencies": {
    "brunch": "^2.0.4",
    "cssnano-brunch": "^1.1.5",
    "javascript-brunch": "^1.8.0",
    "sass-brunch": "^1.9.2",
    "uglify-js-brunch": "^1.7.8"
  },
  "dependencies": {
    "jquery": "^2.1.4"
  }
}

This question is related to node.js npm

The answer is


You can use the short way for installation dependencies only for development as follows:

npm i -D <dependencies-names>

I had a similar problem. npm install --only=dev didn't work, and neither did npm rebuild. Ultimately, I had to delete node_modules and package-lock.json and run npm install again. That fixed it for me.


Check if npm config production value is set to true. If this value is true, it will skip over the dev dependencies.

Run npm config get production

To set it: npm config set -g production false


make sure you don't have env variable NODE_ENV set to 'production'.

If you do, dev dependencies will not be installed without the --dev flag


I had a package-lock.json file from an old version of my package.json, I deleted that and then everything installed correctly.


Got a similar error after running npm-check-updates -u. Solved it by removing node_modules folder and package-lock.json. After that a new npm install and everything worked.

My exception:

Failed to load parser '@typescript-eslint/parser' declared in 'package.json ยป eslint-config-react-app#overrides[0]': Cannot find module '@typescript-eslint/parser'


So the way I got around this was in the command where i would normally run npm install or npm ci, i added NODE_ENV=build, and then NODE_ENV=production after the command, so my entire command came out to:

RUN NODE_ENV=build && npm ci && NODE_ENV=production

So far I haven't had any bad reactions, and my development dependencies which are used for building the application all worked / loaded correctly.

I find this to be a better solution than adding an additional command like npm install --only=dev because it takes less time, and enables me to use the npm ci command, which is faster and specifically designed to be run inside CI tools / build scripts. (See npi-ci documentation for more information on it)


I have the same issue because I set the NODE_ENV=production while building Docker. Then I add one more npm install --only=dev. Everything works fine. I need the devDependencies for building TypeSciprt modules

RUN npm install
RUN npm install --only=dev

Make sure your package.json is valid...

I had the following error...

npm WARN Invalid name: "blah blah blah"

and that, similarly, caused devDependencies not to be installed.

FYI, changing the package.json "name" to blah-blah-blah fixed it.


Examples related to node.js

Hide Signs that Meteor.js was Used Querying date field in MongoDB with Mongoose SyntaxError: Cannot use import statement outside a module Server Discovery And Monitoring engine is deprecated How to fix ReferenceError: primordials is not defined in node UnhandledPromiseRejectionWarning: This error originated either by throwing inside of an async function without a catch block dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error running php after installing node with brew on Mac internal/modules/cjs/loader.js:582 throw err DeprecationWarning: Buffer() is deprecated due to security and usability issues when I move my script to another server Please run `npm cache clean`

Examples related to npm

What does 'x packages are looking for funding' mean when running `npm install`? error: This is probably not a problem with npm. There is likely additional logging output above Module not found: Error: Can't resolve 'core-js/es6' Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist` ERROR in The Angular Compiler requires TypeScript >=3.1.1 and <3.2.0 but 3.2.1 was found instead DeprecationWarning: Buffer() is deprecated due to security and usability issues when I move my script to another server Please run `npm cache clean` What exactly is the 'react-scripts start' command? On npm install: Unhandled rejection Error: EACCES: permission denied Difference between npx and npm?