Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 691
Sean Mackesey Avatar asked Dec 24 '13 17:12

Sean Mackesey


People also ask

How do I fix dependencies in npm?

Audit. Npm has an audit functionality that can be used to identify which packages are responsible for the vulnerabilities. The easy fix is to use the npm audit --fix which will look for updates that can be updated to fix those automatically. But those are usually already fixed or not the real problem.

How install npm with all dependencies?

NPM installs devDependencies within the package. json file. The 'npm install' command should add all the dependencies and devDependencies automatically during installation. If you need to add specific devDependencies to your project, you can use this command- 'npm install --save-dev'.

What does unmet dependencies mean?

Sometimes you get “The following packages have unmet dependencies” error during installation or upgrade of a particular package in Ubuntu. This error occurs if you install package using apt-get command and it is unable to find/install some of the upstream packages required for successful installation.


1 Answers

I believe it is because the dependency resolution is a bit broken, see https://github.com/npm/npm/issues/1341#issuecomment-20634338

Following are the possible solution :

  1. Manually need to install the top-level modules, containing unmet dependencies: npm install [email protected]

  2. Re-structure your package.json. Place all the high-level modules (serves as a dependency for others modules) at the bottom.

  3. Re-run the npm install command.

The problem could be caused by npm's failure to download all the package due to timed-out or something else.

Note: You can also install the failed packages manually as well using npm install [email protected].

Before running npm install, performing the following steps may help:

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

Why 'removing node_modules' sometimes is necessary? When 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

like image 58
dule Avatar answered Oct 18 '22 04:10

dule