Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

npm install --dev is installing devDependencies recursively #5554

Closed
piranna opened this issue Jun 26, 2014 · 13 comments
Closed

npm install --dev is installing devDependencies recursively #5554

piranna opened this issue Jun 26, 2014 · 13 comments

Comments

@piranna
Copy link

piranna commented Jun 26, 2014

I have seen some extrange behaviours of the --dev flag when trying to install a package that could not be able to seen explained anywhere, and in fact only was able to find contradictory info:

  • npm install on a package directory install on node_modules both its dependencies and devDependencies, but only the ones defined on package.json file (just one level, not recursive). This package would be usually fetch from a git repository, since if done correctly, the package hosted on the NPM registry should contains the production-only files, since development files like Gruntfile.js or tests are mostly of interest only for developers of the package, and this ones will fetch it from a source code repository where to push changes later.
  • npm install <package> install that package inside node_modules with its dependencies, but not its devDependencies.

This ones work as expected. Now, the problematic ones:

  • npm install --dev on a package directory install on node_modules both its dependencies and devDependencies, but it also installs recursivelly all the devDependencies of the packages defined on dependencies and devDependencies.
  • npm install <package> --dev install that package inside node_modules with its dependencies, and also installs recursivelly all the devDependencies of itself and its dependencies.

Is this on purpose, or is a bug? Didn't find any info regarding this, but seems in fact it's not a desirable behaviour and was commented to document it explicitly, but acording to NPM config documentation, production flag is disabled by default installing both dependencies and devDependencies, and when enabled, it only installs dependencies. On the other hand, dev flag is also disabled by default, and when enabled, it install devDependencies, what I find conflicts with production flag (if they are installed by default, why to have a flag to install them? More than this, why instead it install ALL of them recursively? I find this behaviour really error prone, and it's use a waste of space and band-width and can't think of any real use case), so this lead me to think...

...should --dev flag removed altogether since now is mostly useless and error prone?

@CGavrila
Copy link

I have encountered the same issue, first of all npm install did not install the devDependencies, and when adding the --dev flag, it started to recursively download all the devDependencies down the line.

The easiest way to overcome this was to join the dependencies and devDependencies fields in the package.json file and do an npm update.

My guess is that a better solution should exist.

@haoqunjiang
Copy link

While npm install works well on my Mac OS X 10.9.4, I've encountered the same issue as @CGavrila mentioned on a CentOS 6.5 server. Should it be identified as a platform-specific issue?

@binarykitchen
Copy link

+1 yeah, I experience the same problem. npm install -dev goes on forever and crashed my server (due to high load)

@zweifisch
Copy link

npm install dose install devDependencies with npm version 1.4.9

@othiym23
Copy link
Contributor

We're going to solve this problem by removing npm install --dev altogether, because it is a huge footgun and nobody has been able to come up with a valid use case for it. See #6200 for details.

@CamiloMM
Copy link

CamiloMM commented Dec 4, 2014

@othiym23 You guys should really remove it, because it's very confusing.

I mean, you'd expect npm install wouldn't install dev dependencies, then run npm install --dev, then your cat dies and your house catches on fire. Not cool.

@hueitan
Copy link

hueitan commented May 13, 2015

I'm facing the same problem on using npm install --dev.

@kenany
Copy link
Contributor

kenany commented May 13, 2015

@huei90 That's why it's going away :)

@hueitan
Copy link

hueitan commented May 13, 2015

Ok @kenany I saw that. Thanks!

danshick added a commit to danshick/koko that referenced this issue May 27, 2015
…s and merged with regular deps (due to recursive dl, see: npm/npm#5554). Built gulpfile that can run multiplatform and can build asar files. Needs final packaging.
danshick added a commit to danshick/koko that referenced this issue May 27, 2015
…s and merged with regular deps (due to recursive dl, see: npm/npm#5554). Built gulpfile that can run multiplatform and can build asar files. Needs final packaging.
@ptpavankumar-myob
Copy link

this has changed now...please use
npm install --only=dev

@piranna
Copy link
Author

piranna commented Feb 2, 2016 via email

@Dev-Dipesh
Copy link

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

@PerspectivesLab
Copy link

npm install --only=dev,
doesnt install sub modules dev dependencies, only devDependencies of the main project.....

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests