[node.js] 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?

This question is related to node.js dependencies npm

The answer is


Some thing in the similar vein, I would add one other step.

Note that on npm version > 1.4.9, 'npm install' does install devDependencies. First try removing existing modules and cache:

remove node_modules $ rm -rf node_modules/
run $ npm cache clean

Then try:

npm install --dev
npm update --dev

This at least will resolve the recursive dependency resolution.


The above answers didn't help me fully even after deleteting node_modules directory.

Below command helped me finally:

npm config set registry http://registry.npmjs.org/

Note that this pulls node modules over an insecure HTTP connection.

Src: https://stackoverflow.com/a/13119867/4082503


In my case, the update of npm solved it.

sudo npm install -g npm

I encountered this problem when I was installing react packages and this worked for me: npm install --save <package causing this error>


npm install will install all the packages from npm-shrinkwrap.json, but might ignore packages in package.json, if they're not preset in the former.

If you're project has a npm-shrinkwrap.json, make sure you run npm shrinkwrap to regenerate it, each time you add add/remove/change package.json.


Upgrading NPM to the latest version can greatly help with this. dule's answer above is right to say that dependency management is a bit broken, but it seems that this is mainly for older versions of npm.

The command npm list gives you a list of all installed node_modules. When I upgraded from version 1.4.2 to version 2.7.4, many modules that were previously flagged with WARN unmet dependency were no longer noted as such.

To update npm, you should type npm install -g npm on MacOSX or Linux. On Windows, I found that re-downloading and re-running the nodejs installer was a more effective way to update npm.


I run npm list and installed all the packages listed as UNMET DEPENDENCY

For instance:

+-- UNMET DEPENDENCY css-loader@^0.23.1
npm install css-loader@^0.23.1


For every -- UNMET PEER DEPENDENCY, for ex. -- UNMET PEER DEPENDENCY [email protected], install that dependency with npm install --save [email protected] until you don't have any more UNMET DEPENDENCIES.

Good Luck.


Take care about your angular version, if you work under angular 2.x.x so maybe you need to upgrade to angular 4.x.x

Some dependencies needs angular 4

Here is a tutorial for how to install angular 4 or update your project.


Updating to 4.0.0

Updating to 4 is as easy as updating your Angular dependencies to the latest version, and double checking if you want animations. This will work for most use cases.

On Linux/Mac:

npm install @angular/{common,compiler,compiler-cli,core,forms,http,platform-browser,platform-browser-dynamic,platform-server,router,animations}@latest typescript@latest --save 

On Windows:

npm install @angular/common@latest @angular/compiler@latest @angular/compiler-cli@latest @angular/core@latest @angular/forms@latest @angular/http@latest @angular/platform-browser@latest @angular/platform-browser-dynamic@latest @angular/platform-server@latest @angular/router@latest @angular/animations@latest typescript@latest --save

Then run whatever ng serve or npm start command you normally use, and everything should work.

If you rely on Animations, import the new BrowserAnimationsModule from @angular/platform-browser/animations in your root NgModule. Without this, your code will compile and run, but animations will trigger an error. Imports from @angular/core were deprecated, use imports from the new package

import { trigger, state, style, transition, animate } from '@angular/animations';.

--dev installing devDependencies recursively (and its run forever..) how it can help to resolve the version differences?

You can try remove the node_moduls folder, then clean the npm cache and then run 'npm i' again


I fixed the issue by using these command lines

  • $ rm -rf node_modules/
  • $ sudo npm update -g npm
  • $ npm install

It's done!


It happened to me when the WIFI went down during an npm install. Removing node_modules and re-running npm install fixed it.


I had a similar issue while I was installing the React Native CLI. I wasn't sure which /node_modules directory I was supposed to remove after reading the answers here. I eventually just ran

npm update -g

and was able to install the package after that.


I was trying to work on an automated deployment system that runs npm install, so a lot of these solutions wouldn't work for me in an automated fasion. I wasn't in a position to go deleting/re-creating node_modules/ nor could I easily change Node.js versions.

So I ended up running npm shrinkwrap - adding the npm-shrinkwrap.json file to my deployment bundle, and running installs from there. That fixed the problem for me; with the shrinkwrap file as a 'helper', npm seemed to be able to find the right packages and get them installed for me. (Shrinkwrap has other features as well, but this was what I needed it for in this particular case).


This solved it for me:

  1. Correct the version numbers in package.json, according to the errors;
  2. Remove node_modules (rm -rf node_modules);
  3. Rerun npm install.

Repeat these steps until there are no more errors.


Examples related to node.js

Hide Signs that Meteor.js was Used Querying date field in MongoDB with Mongoose SyntaxError: Cannot use import statement outside a module Server Discovery And Monitoring engine is deprecated How to fix ReferenceError: primordials is not defined in node UnhandledPromiseRejectionWarning: This error originated either by throwing inside of an async function without a catch block dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error running php after installing node with brew on Mac internal/modules/cjs/loader.js:582 throw err DeprecationWarning: Buffer() is deprecated due to security and usability issues when I move my script to another server Please run `npm cache clean`

Examples related to dependencies

Upgrading React version and it's dependencies by reading package.json How do I deal with installing peer dependencies in Angular CLI? RHEL 6 - how to install 'GLIBC_2.14' or 'GLIBC_2.15'? Automatically create requirements.txt node.js TypeError: path must be absolute or specify root to res.sendFile [failed to parse JSON] MavenError: Failed to execute goal on project: Could not resolve dependencies In Maven Multimodule project npm install private github repositories by dependency in package.json Find unused npm packages in package.json Failed to load c++ bson extension Maven dependency update on commandline

Examples related to npm

What does 'x packages are looking for funding' mean when running `npm install`? error: This is probably not a problem with npm. There is likely additional logging output above Module not found: Error: Can't resolve 'core-js/es6' Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist` ERROR in The Angular Compiler requires TypeScript >=3.1.1 and <3.2.0 but 3.2.1 was found instead DeprecationWarning: Buffer() is deprecated due to security and usability issues when I move my script to another server Please run `npm cache clean` What exactly is the 'react-scripts start' command? On npm install: Unhandled rejection Error: EACCES: permission denied Difference between npx and npm?