Why does npm insist about "UNMET PEER DEPENDENCY"? - node.js

I searched and read many posts about "npm UNMET PEER DEPENDENCY" issues. But this one is still confusing:
Hulk node_modules # npm install -g rxjs#5.0.0-beta.6
- symbol-observable#0.2.4 node_modules/rxjs/node_modules/symbol-observable
/usr/lib
└── rxjs#5.0.0-beta.6
Hulk node_modules # npm install -g zone.js#^0.6.6
/usr/lib
└── zone.js#0.6.12
Hulk node_modules #
Hulk node_modules #
Hulk node_modules #
Hulk node_modules #
Hulk node_modules # npm install -g #angular/core
/usr/lib
├── #angular/core#2.0.0-rc.1
├── UNMET PEER DEPENDENCY rxjs#5.0.0-beta.6
└── UNMET PEER DEPENDENCY zone.js#^0.6.6
npm WARN #angular/core#2.0.0-rc.1 requires a peer of rxjs#5.0.0-beta.6 but none was installed.
npm WARN #angular/core#2.0.0-rc.1 requires a peer of zone.js#^0.6.6 but none was installed.
First when I try to install "#angular/core", npm complained about dependencies.
I installed those dependencies, it still complains.
Why? Thanks for your insights.

Try:
In unix terminal:
remove your node modules:
$ rm -rf node_modules
clear cache:
$ npm cache clean
reinstall (assuming your package.json is correct):
$ npm install

Related

npm unable to install karma-jasmine on my mac

When i install karma-jasmine on mac,it gives me errors:
├── UNMET PEER DEPENDENCY jasmine-core#*
└── karma-jasmine#0.3.8
npm WARN karma-jasmine#0.3.8 requires a peer of jasmine-core#* but none was installed.
But,i have installed jasmine-core just before.
npm install jasmine-core -g
/Users/hbowang/.nvm/versions/node/v5.9.0/lib
└── jasmine-core#2.4.1
Any body can help me resolve this error?
I also got this error, but my package.json file is also missing so by creating package json file i am able to install jasmine-core and karma-jasmine.
For creating package.json file:
$ npm init
then after install jasmine-core:
$ npm install jasmine-core
$ npm install karma --save-dev
$ npm install karma-jasmine --save-dev
Hope it will help!!
you are installing jasmine-core with the global flag.
try installing it without the -g option and then retry.
notice the words UNMET PEER DEPENDENCY which suggests it wants it installed at the same level not globally maybe?

How to install npm peer dependencies automatically?

For example, when I install Angular2:
npm install --save angular2
temp#1.0.0 /Users/doug/Projects/dougludlow/temp
├── angular2#2.0.0-beta.3
├── UNMET PEER DEPENDENCY es6-promise#^3.0.2
├── UNMET PEER DEPENDENCY es6-shim#^0.33.3
├── UNMET PEER DEPENDENCY reflect-metadata#0.1.2
├── UNMET PEER DEPENDENCY rxjs#5.0.0-beta.0
└── UNMET PEER DEPENDENCY zone.js#0.5.11
npm WARN angular2#2.0.0-beta.3 requires a peer of es6-promise#^3.0.2 but none was installed.
npm WARN angular2#2.0.0-beta.3 requires a peer of es6-shim#^0.33.3 but none was installed.
npm WARN angular2#2.0.0-beta.3 requires a peer of reflect-metadata#0.1.2 but none was installed.
npm WARN angular2#2.0.0-beta.3 requires a peer of rxjs#5.0.0-beta.0 but none was installed.
npm WARN angular2#2.0.0-beta.3 requires a peer of zone.js#0.5.11 but none was installed.
Is there a magic flag that I can pass to npm that will install the peer dependencies as well? I haven't been able to find one... It's tedious to manually copy and paste the peer dependencies and make sure I have the correct versions.
In other words, I'd rather not have to do:
npm install --save angular2#2.0.0-beta.3 es6-promise#^3.0.2 es6-shim#^0.33.3 reflect-metadata#0.1.2 rxjs#5.0.0-beta.0 zone.js#0.5.11
What is the better way?
npm version 7 and newer
npm v7 has reintroduced the automatic peerDependencies installation. Now in V7, as in versions before V3, you only need to do an npm i and all peerDependences should be automatically installed.
They had made some changes to fix old problems as version compatibility across multiple dependants.
You can see the discussion and the announcement.
Older Answer
The automatic install of peer dependencies was explicitly removed with npm 3, as it cause more problems than it tried to solve. You can read about it here for example:
https://blog.npmjs.org/post/110924823920/npm-weekly-5
https://github.com/npm/npm/releases/tag/v3.0.0
So no, for the reasons given, you cannot install them automatically with npm 3 upwards.
I solved it by rewriting package.json with the exact values warnings were about.
Warnings when running npm:
npm WARN angular2#2.0.0-beta.3 requires a peer of es6-shim#^0.33.3 but none was installed.
npm WARN angular2#2.0.0-beta.3 requires a peer of reflect-metadata#0.1.2
In package.json, write
"es6-shim": "^0.33.3",
"reflect-metadata": "0.1.2",
Then, delete node_modules directory.
Finally, run the command below:
npm install
Cheat code helpful in this scenario and some others...
├── UNMET PEER DEPENDENCY #angular/common#4.0.2
├── UNMET PEER DEPENDENCY #angular/compiler#4.0.2
├── UNMET PEER DEPENDENCY #angular/compiler-cli#4.0.2
├── UNMET PEER DEPENDENCY #angular/core#4.0.2
├── UNMET PEER DEPENDENCY #angular/forms#4.0.2
├── UNMET PEER DEPENDENCY #angular/http#4.0.2
├── UNMET PEER DEPENDENCY #angular/platform-browser#4.0.2
├── UNMET PEER DEPENDENCY #angular/platform-browser-dynamic#4.0.2 >
copy & paste your error into your code editor.
Highlight an unwanted part with your curser. In this case ├── UNMET PEER DEPENDENCY
Press command + d a bunch of times.
Press delete twice. (Press space if you accidentally highlighted ├── UNMET PEER DEPENDENCY )
Press up once. Add npm install
Press down once. Add --save
Copy your stuff back into the cli and run
npm install #angular/common#4.0.2 #angular/compiler#4.0.2 #angular/compiler-cli#4.0.2 #angular/core#4.0.2 #angular/forms#4.0.2 #angular/http#4.0.2 #angular/platform-browser#4.0.2 #angular/platform-browser-dynamic#4.0.2 --save
I experienced these errors when I was developing an npm package that had peerDependencies. I had to ensure that any peerDependencies were also listed as devDependencies. The project would not automatically use the globally installed packages.
The project npm-install-peers will detect peers and install them.
As of v1.0.1 it doesn't support writing back to the package.json automatically, which would essentially solve our need here.
Please add your support to issue in flight: https://github.com/spatie/npm-install-peers/issues/4
I was facing the same issue, lucky I found an alternative way to install peer dependencies along with the install command.
Step 1: $ npm i npm-install-peers -D
for more clarity about the plugin: https://www.npmjs.com/package/npm-install-peers
Step 2: Update package.json for magical script
....
"scripts": {
...
"postinstall": "npm-install-peers"
},
....
Step 3: Just need to hit the install command to get installed all plugins
$ npm install
Install yarn and then run:
yarn global add install-peerdeps

How to Stop Yeoman AngularJS Giving Errors Even though Karma Installed Globally

I'm trying to start a Yeoman AngularJS project and I receive the following errors at the end of the project install. I have installed all of these modules via npm install -g karma and npm install -g phantomjs. Why am I still seeing these errors even though I globally installed karma and phantomjs?
├── UNMET PEER DEPENDENCY jasmine-core#*
├── UNMET PEER DEPENDENCY karma#^0.13.0 || >= 0.14.0-rc.0
├── karma-jasmine#0.3.6
├─┬ karma-phantomjs-launcher#0.2.3
│ └── lodash#3.10.1
└── UNMET PEER DEPENDENCY phantomjs#>=1.9
npm WARN karma-phantomjs-launcher#0.2.3 requires a peer of karma#>=0.9 but none was installed.
npm WARN karma-phantomjs-launcher#0.2.3 requires a peer of phantomjs#>=1.9 but none was installed.
npm WARN karma-jasmine#0.3.6 requires a peer of jasmine-core#* but none was installed.
npm WARN grunt-karma#0.12.1 requires a peer of karma#^0.13.0 || >= 0.14.0-rc.0 but none was installed.

node - cordova . "unmet dependency"

i tried to clean the cache and install it again but it says a warning unmet dependency
C:\Users\Ralph>npm cache clean
C:\Users\Ralph>npm install -g cordova
C:\Users\Ralph\AppData\Roaming\npm\cordova -> C:\Users\Ralph\AppData\Roaming\npm
\node_modules\cordova\bin\cordova
npm WARN unmet dependency C:\Users\Ralph\AppData\Roaming\npm\node_modules\phoneg
ap\node_modules\connect-phonegap requires shelljs#'0.2.6' but will load
npm WARN unmet dependency C:\Users\Ralph\AppData\Roaming\npm\node_modules\phoneg
ap\node_modules\shelljs,
npm WARN unmet dependency which is version 0.1.4
npm WARN unmet dependency C:\Users\Ralph\AppData\Roaming\npm\node_modules\phoneg
ap\node_modules\cordova\node_modules\plugman requires request#'2.22.0' but will
load
npm WARN unmet dependency C:\Users\Ralph\AppData\Roaming\npm\node_modules\phoneg
ap\node_modules\cordova\node_modules\request,
npm WARN unmet dependency which is version 2.21.0
cordova#4.2.0 C:\Users\Ralph\AppData\Roaming\npm\node_modules\cordova
├── underscore#1.7.0
├── q#1.0.1
├── nopt#3.0.1 (abbrev#1.0.5)
└── cordova-lib#4.2.0 (valid-identifier#0.0.1, osenv#0.1.0, properties-parser#0.
2.3, bplist-parser#0.0.6, mime#1.2.11, unorm#1.3.3, semver#2.0.11, shelljs#0.3.0
, rc#0.5.2, dep-graph#1.1.0, npm#1.4.28, elementtree#0.1.5, xcode#0.6.7, through
2#0.6.3, npmconf#0.1.16, glob#4.0.6, plist#1.1.0, tar#1.0.2, request#2.47.0, d8#
0.4.4, cordova-js#3.7.3)
thank you in advance
Cordova cannot run on the latest version of Node because it actually requires v10.x of Node. So, here is how I avoided the "Warning: unmet dependency" when installing Cordova:
> npm uninstall -g cordova
Use n (nvm for Windows) to downgrade an older version of Node (Windows users will need to downgrade and use):
> n 0.10.40
> npm cache clean
> npm install -g cordova
If you want to install Ionic, then in step 4, call the npm command to directly install ionic (with no #latest) instead of cordova, like this:
> npm install -g ionic
Note: Linux / OSX users may need to prepend the npm commands with "sudo".

Error when installing Grunt

Hello I recently tried installing grunt-command line interface according to the instructions on their website using the node package manager command
sudo npm install -g grunt-cli
It didnt work and I got the following errors
/usr/local/bin/grunt -> /usr/local/lib/node_modules/grunt-cli/bin/grunt
npm WARN unmet dependency /usr/local/lib/node_modules/npm/node_modules/couch-login requires request#'~2.9.202' but will load
npm WARN unmet dependency /usr/local/lib/node_modules/npm/node_modules/request,
npm WARN unmet dependency which is version 2.30.0
grunt-cli#0.1.13 /usr/local/lib/node_modules/grunt-cli
├── resolve#0.3.1
├── nopt#1.0.10 (abbrev#1.0.5)
└── findup-sync#0.1.3 (lodash#2.4.1, glob#3.2.11)
➜ ~
I'm not sure how i update this dependancy. Can anyone shed any light on this?
Try the following:
npm cache clean
npm install -g npm (update npm)
reinstall node.js completely (if all fails).
Please let me know if this works.

Resources