1

I'm well aware npm dependencies are tree shaped, and that two different modules can load two different versions of a dependency at the same time.

So when I see an npm error like:

npm WARN unmet dependency /somedir/node_modules/gulp-browserify
/node_modules/browserify/node_modules/module-deps 
requires stream-combiner@'~0.1.0' but will load /somedir/node_modules
/gulp-browserify/node_modules/browserify/node_modules/stream-combiner, 
which is version 0.0.4

Why doesn't npm install the module-deps dependency (stream-combiner@'~0.1.0') underneath module_deps/node_modules/stream-combiner?

Or, more generally: why does npm sometimes not install a module where it is needed, using a different version on that module from elsewhere in the dependency tree instead?

mikemaccana
  • 110,530
  • 99
  • 389
  • 494
  • That looks like a bug to me :P Do you really wanna know what's the reason the bug happens? – Farid Nouri Neshat Feb 26 '15 at 16:03
  • This might help: https://docs.npmjs.com/cli/install#algorithm, https://docs.npmjs.com/files/folders#cycles-conflicts-and-folder-parsimony ... although they always say that only packages are shared if they have the same version. – Felix Kling Feb 26 '15 at 16:10
  • Related (duplicate?): http://stackoverflow.com/q/20764881/218196 – Felix Kling Feb 26 '15 at 16:15
  • Is there a command I can run to reproduce this? I just ran `npm install gulp-browserify` and I [successfully](https://gist.github.com/KenanY/53b4dfa7a50b42b872c0) get two different versions of `stream-combiner`. – Kenan Feb 26 '15 at 16:17
  • @Kenan it's from a long `npm-shrinkwrap` file, I'll spent the time to cut it down if I don't get any answers, but I think most people using npm have seen this before. – mikemaccana Feb 26 '15 at 16:32
  • @mikemaccana Since `npm install` will follow `npm-shrinkwrap.json` to the letter, this sounds like it might be an issue with your shrinkwrap file instead. If you don't have `stream-combiner@0.1.0` anywhere in there of course `npm install` won't install it. – Kenan Feb 26 '15 at 17:04
  • @mikemaccana Sorry, I don't mean to say anything like that. Of course `module-deps` needs it. I'm just proposing the possibility that the shrinkwrap file is a fault here, especially considering how a regular `npm install gulp-browserify` does not reproduce your issue. I'm hypothesizing that the dependency you're missing is not defined in your shrinkwrap file, hence `npm install` will not install the dependency. – Kenan Feb 26 '15 at 17:20
  • @Kenan OK. But deleting the shrinkwrap file and running `npm update` doesn't help. There are many instances of this error: `/somedir/node_modules/gulp-sass/node_modules/node-sass/node_modules/mocha/node_modules/jade requires mkdirp@'0.3.0' but will load /somedir/node_modules/gulp-sass/node_modules/node-sass/node_modules/mkdirp which is version 0.5.0`, – mikemaccana Feb 26 '15 at 17:25

0 Answers0