Sean Mackesey Sean Mackesey - 8 months ago 32
Node.js Question

Why does npm install say I have unmet dependencies?

I have a node package. When I run

npm install
from the package root, it installs a bunch of things, but then prints several error messages that look like this:

npm WARN unmet dependency /Users/seanmackesey/google_drive/code/explore/generator/node_modules/findup-sync/node_modules/glob requires graceful-fs@'~1.2.0' but will load

I must be confused about what exactly
npm install
does. If it detects a dependency, shouldn't it install it? Under what conditions does it give me error messages like this, and how can I resolve the dependencies?


I believe it is because the dependency resolution is a bit broken, see

You may need to manually install top-level modules that have unmet dependencies:

npm install findup-sync@0.1.2

Or structure your package.json such that any top-level modules that are also dependencies of other modules are listed lower down.

Your problem could also be that npm failed to download the package, timed-out or whatnot. Sometimes re-running npm install remedies it. You can also install the failed packages manually as well using npm install findup-sync@0.1.2.

Other steps that may help before attempting npm install again are:

  • remove node_modules using rm -rf node_modules/
  • run npm cache clean

To explain why removing node_modules sometimes is necessary: Apparently if a nested module fails to install during npm install, subsequent npm install won't detect those missing nested dependencies. If that's the case, sometimes it's sufficient to remove the top-level dependency of those missing nested modules, and running npm install again. See