[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


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


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


I fixed the issue by using these command lines

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

It's done!


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.


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


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.


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


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.


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


In my case, the update of npm solved it.

sudo npm install -g npm

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.


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).


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.


--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


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.


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';.

Questions with node.js tag:

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` jwt check if token expired Using Environment Variables with Vue.js Avoid "current URL string parser is deprecated" warning by setting useNewUrlParser to true Can not find module “@angular-devkit/build-angular” MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017] MySQL 8.0 - Client does not support authentication protocol requested by server; consider upgrading MySQL client npx command not found await is only valid in async function What could cause an error related to npm not being able to find a file? No contents in my node_modules subfolder. Why is that? How to set bot's status Returning data from Axios API Error: EACCES: permission denied, access '/usr/local/lib/node_modules' ReferenceError: fetch is not defined ERROR in Cannot find module 'node-sass' Test process.env with Jest 'react-scripts' is not recognized as an internal or external command NPM Install Error:Unexpected end of JSON input while parsing near '...nt-webpack-plugin":"0' db.collection is not a function when using MongoClient v3.0 When I run `npm install`, it returns with `ERR! code EINTEGRITY` (npm 5.3.0) E: Unable to locate package npm How can the default node version be set using NVM? How to downgrade Node version How to solve npm install throwing fsevents warning on non-MAC OS? How to read file with async/await properly? Angular: Cannot Get / The difference between "require(x)" and "import x" Is there a way to force npm to generate package-lock.json? Angular - ng: command not found MongoError: connect ECONNREFUSED 127.0.0.1:27017 How can I use async/await at the top level? ERROR in ./node_modules/css-loader? Downgrade npm to an older version Node - was compiled against a different Node.js version using NODE_MODULE_VERSION 51 npm install Error: rollbackFailedOptional npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY How can I use an ES6 import in Node.js? Node.js: Python not found exception due to node-sass and node-gyp bash: npm: command not found? npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Nuwanst\package.json' Laravel 5.4 ‘cross-env’ Is Not Recognized as an Internal or External Command

Questions with dependencies tag:

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 Why does npm install say I have unmet dependencies? How to clean old dependencies from maven repositories? What's the difference between dependencies, devDependencies and peerDependencies in npm package.json file? Android Studio - Importing external Library/Jar Depend on a branch or tag using a git URL in a package.json? scipy.misc module has no attribute imread? Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0 What is Dependency Injection and Inversion of Control in Spring Framework? How do I install package.json dependencies in the current directory using npm Downloading all maven dependencies to a directory NOT in repository? How to check for DLL dependency? Maven: Failed to read artifact descriptor Do you know the Maven profile for mvnrepository.com? How to add local jar files to a Maven project? Could not load file or assembly '***.dll' or one of its dependencies Maven: how to override the dependency added by a library How to get a dependency tree for an artifact? Makefile, header dependencies Which maven dependencies to include for spring 3.0? Maven: add a dependency to a jar by relative path HintPath vs ReferencePath in Visual Studio MSBuild doesn't copy references (DLL files) if using project dependencies in solution Detecting superfluous #includes in C/C++? Exclude all transitive dependencies of a single dependency Add a dependency in Maven How do I determine the dependencies of a .NET application? The located assembly's manifest definition does not match the assembly reference force Maven to copy dependencies into target/lib

Questions with npm tag:

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? Local package.json exists, but node_modules missing npx command not found What could cause an error related to npm not being able to find a file? No contents in my node_modules subfolder. Why is that? SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 Error: EACCES: permission denied, access '/usr/local/lib/node_modules' ERROR in Cannot find module 'node-sass' NPM Install Error:Unexpected end of JSON input while parsing near '...nt-webpack-plugin":"0' When I run `npm install`, it returns with `ERR! code EINTEGRITY` (npm 5.3.0) E: Unable to locate package npm Is there a way to force npm to generate package-lock.json? ERROR in ./node_modules/css-loader? Downgrade npm to an older version Node - was compiled against a different Node.js version using NODE_MODULE_VERSION 51 npm WARN ... requires a peer of ... but none is installed. You must install peer dependencies yourself Error: EPERM: operation not permitted, unlink 'D:\Sources\**\node_modules\fsevents\node_modules\abbrev\package.json' npm install Error: rollbackFailedOptional webpack: Module not found: Error: Can't resolve (with relative path) npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Nuwanst\package.json' Laravel 5.4 ‘cross-env’ Is Not Recognized as an Internal or External Command Why does "npm install" rewrite package-lock.json? The term 'ng' is not recognized as the name of a cmdlet Npm Error - No matching version found for What is the role of the package-lock.json? Do I commit the package-lock.json file created by npm 5? What is the difference between npm install and npm run build? How to resolve Nodejs: Error: ENOENT: no such file or directory Node update a specific package Cannot uninstall angular-cli Field 'browser' doesn't contain a valid alias configuration How can I add a .npmrc file? How to solve npm error "npm ERR! code ELIFECYCLE" You seem to not be depending on "@angular/core". This is an error Why is "npm install" really slow? Checking version of angular-cli that's installed? How to specify a port to run a create-react-app based project? Maximum call stack size exceeded on npm install npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected] How to clear cache in Yarn? How to update TypeScript to latest version with npm?