Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

npm installs fibers once per dependent module... strangeness ensues #102

willconant opened this Issue Jan 24, 2013 · 7 comments


None yet
6 participants

If I have a package that both depends on fibers and depends on a package that depends on fibers, I end up with two copies of fibers which seems to screw up Fiber.current because, I presume, there is more than one "global" Fiber object.

Hypothetical directory structure created by npm:


When I get a future from cot-fibers and try to wait within a fiber, I get "Can't wait without a fiber" even though I'm definitely within a fiber. If I delete the nested fibers install and try again, everything is fine.

Does this sound like a plausible issue? Or am I just doing something screwy?

NPM doesn't work that way. I must have done things in a silly order to produce a pathological node_modules directory structure with two copies of fibers. Cheers!

@willconant willconant closed this Jan 31, 2013


laverdet commented Jan 31, 2013

No npm certainly does do this and a solution is needed. :)

@laverdet laverdet reopened this Jan 31, 2013

If you look at the "Algorithm" section of the npm-install docs (https://npmjs.org/doc/install.html), it explains that sub-modules will only have their dependencies installed in their own node_modules directory if a module higher up doesn't already have that dependency.

I ended up with two copies of fibers because I did things in this order:

  1. create private module that depends on cot-fibers which, in turn, depends on fibers
  2. run npm install in private module directory
  3. realize I needed to be able to require('fibers') in my module and add fibers as dependency
  4. run npm install again

I imagine this is a fairly common mistake for anyone writing a module with fibers, and the error message when this happens isn't particularly helpful, so it probably could use some attention. But it was still somewhat a case of user error.

olegp commented Feb 10, 2013

npm prune may be one solution to this

scriby commented Feb 25, 2013

I've worked around something similar to this by not specifying a specific version of the module. Something like "fibers": "*". So as long as a version of it was installed by something else, it would use the same version.

You should look into the "peerDependency" feature of npm. Also would make sense not to have modules that require fibers install fibers. This seems more like an app level decision.

@lalomartins lalomartins referenced this issue in arunoda/laika Feb 12, 2014


Expose Fibers and Future to plug-ins #86

I found that peerDependency won't necessarily help. In our case, laika-webdriver will peerDepend on laika, and laika depends on fibers. All well and dandy, but laika-webdriver still doesn't have access to the Fibers copy inside laika.

@laverdet laverdet closed this in d9bc3a7 Jan 3, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment