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
Related
I have errors when want to install npm install node-saas
├── UNMET PEER DEPENDENCY react#15.4.2
└── UNMET PEER DEPENDENCY react-dom#15.4.2
npm ERR! peer dep missing: react#^0.14.1, required by
react-select#0.9.1
npm ERR! peer dep missing: react-dom#^0.14.1, required by
react-select#0.9.1
npm ERR! code 1
Please help, Thank you very much.
I think you forgot to install react and react-dom, first run this command it will install react and react-dom properly with all dependencies, after that run other commands.
npm install react react-dom --save
By using --save it will make a entry in package.json file, after using above command check your package.json file, these entries will be there:
"react": "^XX.X.X",
"react-dom": "^XX.X.X",
Whenever I do a npm init then npm install react - I get this error
── UNMET PEER DEPENDENCY react#15.3.0
npm WARN baobab-react#0.1.1 requires a peer of react#>=0.13.0 <1.0.0 but none was installed.
npm WARN fixed-data-table#0.4.7 requires a
peer of react#>=0.13.0 <0.15.0 || ^0.14.0-beta3 but none was
installed.
npm WARN react-native#0.30.0 requires a peer of
react#~15.2.0 but none was installed.
npm WARN react-router#0.13.5
requires a peer of react#0.13.x||0.14.x but none was installed. npm
ERR! code 1
This is my node v6.3.0 annd npm 3.10.3 versions.
npm install react --no-optional
Inside your project directory, can you please first run the following commands:-
1) rm -rf node_modules
2) Try installig react again now and other packages which are in your package.json file.
I tried to create a new project using the following command
ionic start BlankApp blank
to create a blank app from Blank templates
Next I run
bower install --save angular-cache
and the installing process stop at
bower angular#>=1.x validate 1.5.6 against https://github.com/angular/bower-angular.git#>=1.x
So I tried using
npm install --save angular-cache
It create a folder named "node_modules" and the following error
ionic-project#1.1.1 /Users/Thipok/Desktop/ProjectSth/Cache-Local
├── UNMET PEER DEPENDENCY angular#>=1.x <2
└── angular-cache#4.6.0
npm WARN angular-cache#4.6.0 requires a peer of angular#>=1.x <2 but none was installed.
npm WARN ionic-project#1.1.1 No repository field.
npm WARN ionic-project#1.1.1 No license field.
I also tried to install cordova-plugin-wkwebview and failed but that is not the question here.
error :
+-- UNMET PEER DEPENDENCY generator-backbone-mocha#>=0.0.2
`-- UNMET PEER DEPENDENCY generator-mocha#>=0.1.3
npm WARN generator-backbone#0.4.0 requires a peer of generator-mocha#>=0.1.3 but none was installed.
npm WARN generator-backbone#0.4.0 requires a peer of generator-backbone-mocha#>=0.0.2 but none was installed.
UNMET PEER DEPENDENCY error means that your dependency (in this case generator-backbone) requires that you explicitly install also something else (in this case, generator-mocha and generator-backbone-mocha). You should just install those dependencies (top level):
npm install generator-backbone#0.4.0 --save
npm install generator-backbone-mocha --save
I ran those commands
AT07684S#ZE0PW0NM /d/AAA_Dev2015
$ npm install -g generator-karma --save
npm WARN deprecated lodash#2.4.2: lodash#<3.0.0 is no longer maintained. Upgrade to lodash#^3.0.0.
C:\Users\AT07684S\AppData\Roaming\npm
└── generator-karma#1.0.1
AT07684S#ZE0PW0NM /d/AAA_Dev2015
$ npm install -g generator-angular --save
npm WARN deprecated lodash#2.4.2: lodash#<3.0.0 is no longer maintained. Upgrade to lodash#^3.0.0.
npm WARN deprecated CSSselect#0.4.1: the module is now available as 'css-select'
npm WARN deprecated CSSwhat#0.4.7: the module is now available as 'css-what'
npm WARN deprecated lodash#2.1.0: lodash#<3.0.0 is no longer maintained. Upgrade to lodash#^3.0.0.
C:\Users\AT07684S\AppData\Roaming\npm
├── generator-angular#0.14.0
└── UNMET PEER DEPENDENCY generator-karma#>=0.9.0
npm WARN EPEERINVALID generator-angular#0.14.0 requires a peer of generator-karma#>=0.9.0 but none was install
ed.
As you can see I first installed generator-karma 1.0.1 but then when I install generator-angular it fails, supposedly because generator-karma>=0.9.0 is not installed.
What could I do?
Thanks
Similar question has already been answered here npm install -g generator-angular gives error (requires a peer of) and here UNMET PEER DEPENDENCY generator-karma#>=0.9.0. Wise people suggest to install everything in one line, so try this:
sudo npm install -g grunt-cli bower yo generator-karma generator-angular
Works for me, it should help You as well.