Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm install won't install devDependencies

Tags:

node.js

npm

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"   } } 
like image 781
Tristan Tzara Avatar asked Jan 10 '16 00:01

Tristan Tzara


People also ask

Does npm install installs devDependencies?

By default, npm install will install all modules listed as dependencies in package. json . With the --production flag (or when the NODE_ENV environment variable is set to production ), npm will not install modules listed in devDependencies .

Why npm is not installing?

On Windows, the cause of this error could be that a PATH or system variable is not correctly set. The error can also occur if you do not have npm or Node. js installed, have an outdated version, or have permission issues.

Do devDependencies get installed?

A: Both dependencies and devDependencies are installed to the local node_modules folder on a yarn install or npm install , but only dependencies - and not devDependencies - are installed to the local node_modules folder when doing a yarn install --production and npm install --production .

Should NPM be the default for devdependencies?

It should be the default! devDependencies are literally dependencies for the developers of the module. I bet most of us npm install a module to use it, rather than develop it. Say you write an app, and you need a logger or webpack plugin. those are devdeps.

How do I install dependencies only for development?

You can use the short way for installation dependencies only for development as follows: Show activity on this post. 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. Show activity on this post.

Where does NPM get its config settings?

npm gets its config settings from the command line, environment variables, and npmrc files. So check environment variables, and the npmrc file. Still failing? Ok, create a new folder, ideally somewhere else on your filesystem. ie. not in same folder hierarchy.


2 Answers

Check the NPM docs for install

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

The --only={prod[uction]|dev[elopment]} argument will cause either only devDependencies or only non-devDependencies to be installed regardless of the NODE_ENV."

Have you tried

npm install --only=dev 

If you are worried that your package.json might be incorrect, best thing to do is this. Create a new folder, and run:

npm init --yes 

Then:

npm install --save-dev brunch@^2.0.4 npm install --save-dev cssnano-brunch@^1.1.5 npm install --save-dev javascript-brunch@^1.8.0 npm install --save-dev sass-brunch@^1.9.2 npm install --save-dev uglify-js-brunch@^1.7.8 npm install jquery@^2.1.4 --save 

And you should be good to go! Otherwise, will keep posting other options.

Check your npm configuration:

npm config list 

npm gets its config settings from the command line, environment variables, and npmrc files. So check environment variables, and the npmrc file.

Still failing?

Ok, create a new folder, ideally somewhere else on your filesystem. ie. not in same folder hierarchy. For instance, C:\myNewFolder - the closer to the base C: drive the better.

Then run:

npm init --yes 

Now run:

npm install underscore --save 

and finally:

npm install mocha --save-dev 

Does everything work as expected?

What I am trying to do is understand whether your problem is global, or something local to the previous folder and dependencies.

like image 92
arcseldon Avatar answered Sep 25 '22 14:09

arcseldon


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

like image 34
Shawn Mclean Avatar answered Sep 21 '22 14:09

Shawn Mclean