411

I tried to run a project downloaded from github. Unfortunately, during npm install the following warnings were shown. I tried to change the version based on this question. However, I had a problem, because some packages require multiple versions other packages. Consider these two lines:

npm WARN @angular/cdk@2.0.0-beta.10 requires a peer of @angular/core@^4.3.0 but none is installed. You must install peer dependencies yourself.

npm WARN @angular/forms@4.3.6 requires a peer of @angular/core@4.3.6 but none is installed. You must install peer dependencies yourself.

So, installing some packages causes the list of dependencies to grow substantially.

Does anyone have a solution?

npm WARN @angular/animations@4.3.6 requires a peer of @angular/core@4.3.6 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/cdk@2.0.0-beta.10 requires a peer of @angular/core@^4.3.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/cdk@2.0.0-beta.10 requires a peer of @angular/common@^4.3.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/compiler@4.3.6 requires a peer of @angular/core@4.3.6 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/compiler-cli@4.3.6 requires a peer of @angular/core@4.3.6 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/forms@4.3.6 requires a peer of @angular/core@4.3.6 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/forms@4.3.6 requires a peer of @angular/common@4.3.6 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/forms@4.3.6 requires a peer of @angular/platform-browser@4.3.6 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/http@4.3.6 requires a peer of @angular/core@4.3.6 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/http@4.3.6 requires a peer of @angular/platform-browser@4.3.6 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/material@2.0.0-beta.10 requires a peer of @angular/core@^4.3.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/material@2.0.0-beta.10 requires a peer of @angular/common@^4.3.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/platform-browser-dynamic@2.4.10 requires a peer of @angular/compiler@2.4.10 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/platform-server@4.3.6 requires a peer of @angular/core@4.3.6 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/platform-server@4.3.6 requires a peer of @angular/common@4.3.6 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/platform-server@4.3.6 requires a peer of @angular/platform-browser@4.3.6 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/router@4.3.6 requires a peer of @angular/core@4.3.6 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/router@4.3.6 requires a peer of @angular/common@4.3.6 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/router@4.3.6 requires a peer of @angular/platform-browser@4.3.6 but none is installed. You must install peer dependencies yourself.
npm WARN angularfire2@2.0.0-beta.7-pre requires a peer of @angular/compiler@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN extract-text-webpack-plugin@3.0.0 requires a peer of webpack@^3.1.0 but none is installed. You must install peer dependencies yourself.

Here are the contents of package.json:

{
  "name": "fireplace",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/name/fireplace.git"
  },
  "author": "name",
  "bugs": {
    "url": "https://github.com/name/fireplace/issues"
  },
  "homepage": "https://github.com/name/fireplace",
  "private": true,
  "dependencies": {
    "@angular/animations": "^4.0.0-rc.2",
    "@angular/common": "^4.0.0-rc.2",
    "@angular/compiler": "^4.0.0-rc.2",
    "@angular/compiler-cli": "^4.0.0-rc.2",
    "@angular/core": "^4.0.0-rc.2",
    "@angular/flex-layout": "^2.0.0-rc.1",
    "@angular/forms": "^4.0.0-rc.2",
    "@angular/http": "^4.0.0-rc.2",
    "@angular/material": "^2.0.0-beta.2",
    "@angular/platform-browser": "^4.0.0-rc.2",
    "@angular/platform-browser-dynamic": "^4.0.0-rc.2",
    "@angular/platform-server": "^4.0.0-rc.2",
    "@angular/router": "^4.0.0-rc.2",
    "@types/lodash": "^4.14.53",
    "angular2-google-maps": "^0.17.0",
    "angular2-moment": "^1.2.0",
    "angularfire2": "^2.0.0-beta.8",
    "core-js": "^2.4.1",
    "d3": "^4.7.1",
    "d3-cloud": "^1.2.4",
    "firebase": "^3.6.10",
    "hammerjs": "^2.0.8",
    "lodash": "^4.17.4",
    "rxjs": "^5.2.0",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.7.6"
  },
  "devDependencies": {
    "@angular/cli": "^1.0.0-rc.1",
    "@angular/compiler-cli": "^2.4.0",
    "@types/jasmine": "2.5.38",
    "@types/node": "~6.0.60",
    "codelyzer": "~2.0.0",
    "jasmine-core": "2.5.2",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.0.0",
    "karma-cli": "~1.0.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-coverage-istanbul-reporter": "^0.2.1",
    "protractor": "~5.1.0",
    "ts-node": "~2.0.0",
    "tslint": "~4.4.2",
    "typescript": "^2.2.1",
    "webpack": "^2.2.1"
  }
}

ng serve returns(I pasted only the beginning and the end):

ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/core/bidi/index.d.ts (8,99): Cannot find module '@angular/cdk/bidi'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/core/portal/portal.d.ts (8,85): Cannot find module '@angular/cdk/portal'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/core/portal/portal-directives.d.ts (8,76): Cannot find module '@angular/cdk/portal'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/core/portal/dom-portal-host.d.ts (8,31): Cannot find module '@angular/cdk/portal'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/core/ripple/ripple-renderer.d.ts (9,26): Cannot find module '@angular/cdk/platform'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/core/ripple/ripple-renderer.d.ts (10,31): Cannot find module '@angular/cdk/scrolling'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/core/ripple/ripple.d.ts (9,31): Cannot find module '@angular/cdk/scrolling'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/core/ripple/ripple.d.ts (10,26): Cannot find module '@angular/cdk/platform'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/core/platform/platform.d.ts (8,26): Cannot find module '@angular/cdk/platform'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/core/keyboard/keycodes.d.ts (8,146): Cannot find module '@angular/cdk/keycodes'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/core/core.d.ts (1,61): Cannot find module '@angular/cdk/coercion'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/core/core.d.ts (2,49): Cannot find module '@angular/cdk/observers'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/core/core.d.ts (3,32): Cannot find module '@angular/cdk/collections'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/core/core.d.ts (9,15): Cannot find module '@angular/cdk/platform'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/core/core.d.ts (10,15): Cannot find module '@angular/cdk/overlay'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/core/core.d.ts (14,252): Cannot find module '@angular/cdk/a11y'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/autocomplete/autocomplete.d.ts (10,44): Cannot find module '@angular/cdk/a11y'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/autocomplete/autocomplete-trigger.d.ts (10,32): Cannot find module '@angular/cdk/bidi'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/autocomplete/autocomplete-trigger.d.ts (11,67): Cannot find module '@angular/cdk/overlay'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/button/button.d.ts (9,26): Cannot find module '@angular/cdk/platform'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/core/a11y/focus-key-manager.d.ts (8,50): Cannot find module '@angular/cdk/a11y'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/chips/chip-list.d.ts (10,33): Cannot find module '@angular/cdk/a11y'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/chips/chip-list.d.ts (11,32): Cannot find module '@angular/cdk/bidi'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/dialog/dialog-config.d.ts (9,27): Cannot find module '@angular/cdk/bidi'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/dialog/dialog-container.d.ts (10,86): Cannot find module '@angular/cdk/portal'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/dialog/dialog-container.d.ts (11,34): Cannot find module '@angular/cdk/a11y'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/dialog/dialog-ref.d.ts (8,28): Cannot find module '@angular/cdk/overlay'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/dialog/dialog.d.ts (10,31): Cannot find module '@angular/cdk/portal'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/dialog/dialog.d.ts (11,62): Cannot find module '@angular/cdk/overlay'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/datepicker/datepicker.d.ts (9,67): Cannot find module '@angular/cdk/overlay'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/datepicker/datepicker.d.ts (10,32): Cannot find module '@angular/cdk/bidi'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/grid-list/grid-list.d.ts (10,32): Cannot find module '@angular/cdk/bidi'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/input/autosize.d.ts (10,26): Cannot find module '@angular/cdk/platform'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/input/input.d.ts (10,26): Cannot find module '@angular/cdk/platform'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/menu/menu-panel.d.ts (10,27): Cannot find module '@angular/cdk/bidi'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/menu/menu-directive.d.ts (14,27): Cannot find module '@angular/cdk/bidi'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/menu/menu-trigger.d.ts (9,43): Cannot find module '@angular/cdk/bidi'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/menu/menu-trigger.d.ts (10,67): Cannot find module '@angular/cdk/overlay'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/select/select.d.ts (10,33): Cannot find module '@angular/cdk/a11y'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/select/select.d.ts (11,32): Cannot find module '@angular/cdk/bidi'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/select/select.d.ts (12,109): Cannot find module '@angular/cdk/overlay'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/select/select.d.ts (14,32): Cannot find module '@angular/cdk/collections'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/select/select.d.ts (19,26): Cannot find module '@angular/cdk/platform'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/core/a11y/focus-trap.d.ts (8,95): Cannot find module '@angular/cdk/a11y'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/slider/slider.d.ts (10,32): Cannot find module '@angular/cdk/bidi'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/slide-toggle/slide-toggle.d.ts (9,26): Cannot find module '@angular/cdk/platform'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/snack-bar/snack-bar-config.d.ts (9,36): Cannot find module '@angular/cdk/a11y'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/snack-bar/snack-bar-config.d.ts (10,27): Cannot find module '@angular/cdk/bidi'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/snack-bar/snack-bar-container.d.ts (10,70): Cannot find module '@angular/cdk/portal'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/snack-bar/snack-bar-ref.d.ts (8,28): Cannot find module '@angular/cdk/overlay'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/snack-bar/snack-bar.d.ts (9,25): Cannot find module '@angular/cdk/overlay'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/snack-bar/snack-bar.d.ts (10,31): Cannot find module '@angular/cdk/portal'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/snack-bar/snack-bar.d.ts (11,31): Cannot find module '@angular/cdk/a11y'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/sort/sort-header.d.ts (9,30): Cannot find module '@angular/cdk/table'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/table/cell.d.ts (9,84): Cannot find module '@angular/cdk/table'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/table/table.d.ts (1,26): Cannot find module '@angular/cdk/table'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/table/row.d.ts (1,66): Cannot find module '@angular/cdk/table'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/tabs/tab-label.d.ts (9,41): Cannot find module '@angular/cdk/portal'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/tabs/tab-body.d.ts (10,53): Cannot find module '@angular/cdk/portal'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/tabs/tab-body.d.ts (11,43): Cannot find module '@angular/cdk/bidi'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/tabs/tab-header.d.ts (9,43): Cannot find module '@angular/cdk/bidi'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/tabs/tab-nav-bar/tab-nav-bar.d.ts (9,31): Cannot find module '@angular/cdk/scrolling'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/tabs/tab-nav-bar/tab-nav-bar.d.ts (10,32): Cannot find module '@angular/cdk/bidi'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/tabs/tab-nav-bar/tab-nav-bar.d.ts (11,26): Cannot find module '@angular/cdk/platform'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/tooltip/tooltip.d.ts (10,34): Cannot find module '@angular/cdk/scrolling'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/tooltip/tooltip.d.ts (12,32): Cannot find module '@angular/cdk/bidi'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/tooltip/tooltip.d.ts (13,26): Cannot find module '@angular/cdk/platform'.
ERROR in /Users/username/Projects/fireplace/node_modules/@angular/material/typings/tooltip/tooltip.d.ts (14,132): Cannot find module '@angular/cdk/overlay'.
ERROR in /Users/username/Projects/fireplace/src/auth/auth.module.ts (24,24): Property 'forRoot' does not exist on type 'typeof MaterialModule'.
ERROR in /Users/username/Projects/fireplace/src/common/data.model.ts (25,14): Type 'Feed' has no properties in common with type 'IFeed'.
ERROR in /Users/username/Projects/fireplace/src/common/data.model.ts (32,14): Type 'Like' has no properties in common with type 'ILike'.
ERROR in /Users/username/Projects/fireplace/src/common/data.model.ts (39,14): Type 'Follower' has no properties in common with type 'IFollower'.
ERROR in /Users/username/Projects/fireplace/src/sign-in/sign-in.module.ts (21,24): Property 'forRoot' does not exist on type 'typeof MaterialModule'.
ERROR in /Users/username/Projects/fireplace/src/word-cloud/word-cloud.component.ts (192,25): Property 'items' does not exist on type '{}'.
ERROR in /Users/username/Projects/fireplace/src/word-cloud/word-cloud.component.ts (192,51): Property 'items' does not exist on type '{}'.
ERROR in Error encountered resolving symbol values statically. Calling function 'OpaqueToken', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol FirebaseUserConfig in /Users/username/Projects/fireplace/node_modules/angularfire2/tokens.d.ts, resolving symbol AngularFireModule.initializeApp in /Users/username/Projects/fireplace/node_modules/angularfire2/angularfire2.d.ts, resolving symbol FirebaseModule in /Users/username/Projects/fireplace/src/firebase/firebase.module.ts, resolving symbol AppModule in /Users/username/Projects/fireplace/src/app/app.module.ts, resolving symbol AppModule in /Users/username/Projects/fireplace/src/app/app.module.ts
ERROR in ./node_modules/@angular/material/@angular/material.es5.js
Module not found: Error: Can't resolve '@angular/cdk/a11y' in '/Users/username/Projects/fireplace/node_modules/@angular/material/@angular'
resolve '@angular/cdk/a11y' in '/Users/username/Projects/fireplace/node_modules/@angular/material/@angular'
  Parsed request is a module
  using description file: /Users/username/Projects/fireplace/node_modules/@angular/material/package.json (relative path: ./@angular)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /Users/username/Projects/fireplace/node_modules/@angular/material/package.json (relative path: ./@angular)
    resolve as module
[/Users/username/Projects/fireplace/node_modules/@angular/cdk/table]
[/Users/username/Projects/fireplace/node_modules/@angular/cdk/table.ts]
[/Users/username/Projects/fireplace/node_modules/@angular/cdk/table.js]
[/Users/username/Projects/fireplace/node_modules/@angular/cdk/table]
[/Users/username/Projects/fireplace/node_modules/@angular/cdk/table]
[/Users/username/Projects/fireplace/node_modules/@angular/cdk/table.ts]
[/Users/username/Projects/fireplace/node_modules/@angular/cdk/table.js]
[/Users/username/Projects/fireplace/node_modules/@angular/cdk/table]
[/Users/username/Projects/fireplace/src/@angular/cdk/table]
[/Users/username/Projects/fireplace/src/@angular/cdk/table.ts]
[/Users/username/Projects/fireplace/src/@angular/cdk/table.js]
[/Users/username/Projects/fireplace/src/@angular/cdk/table]
[/Users/username/Projects/fireplace/src/@angular/cdk/table]
[/Users/username/Projects/fireplace/src/@angular/cdk/table.ts]
[/Users/username/Projects/fireplace/src/@angular/cdk/table.js]
[/Users/username/Projects/fireplace/src/@angular/cdk/table]
 @ ./node_modules/@angular/material/@angular/material.es5.js 34:0-218
 @ ./src/app/app.module.ts
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
ERROR in ./node_modules/css-loader?{"sourceMap":false,"importLoaders":1}!./node_modules/postcss-loader?{"ident":"postcss"}!./node_modules/sass-loader/lib/loader.js?{"sourceMap":false,"precision":8,"includePaths":[]}!./src/theme.scss
Module build failed: 
@import '~@angular/material/core/theming/all-theme';
^
      File to import not found or unreadable: ~@angular/material/core/theming/all-theme.
Parent style sheet: stdin
      in /Users/username/Projects/fireplace/src/theme.scss (line 1, column 1)
Error: 
@import '~@angular/material/core/theming/all-theme';
^
      File to import not found or unreadable: ~@angular/material/core/theming/all-theme.
Parent style sheet: stdin
      in /Users/username/Projects/fireplace/src/theme.scss (line 1, column 1)
    at options.error (/Users/username/Projects/fireplace/node_modules/node-sass/lib/index.js:291:26)
 @ ./src/theme.scss 4:14-186
 @ multi ./src/theme.scss ./src/styles.scss

webpack: Failed to compile.
  • 8
    Okey, but when I do for instance `sudo npm install @angular/core@4.3.6 ` I still have `npm WARN @angular/platform-browser@2.4.10 requires a peer of @angular/core@2.4.10 but none is installed. You must install peer dependencies yourself. ` –  Sep 05 '17 at 11:08
  • These are warnings.you can ignore them. Did you try running the project? Is it working fine?Or you are also getting errors while running – Karan Garg Sep 05 '17 at 11:09
  • @KaranGarg ng serve returns errors. I added them to the updated question. –  Sep 05 '17 at 11:50
  • 9
    @KaranGarg I have a similar issue and would like not to "Ignore warnings" What configuration is needed to not show this type of warning. Note: for my project is `npm WARN react-test-renderer@16.1.1 requires a peer of react@^16.0.0 but none is installed.` and yes I do have the required peer installed. Is this is an issue with my project or an issue with the `react-test-renderer` project? – Matt Nov 22 '17 at 15:29
  • 7
    @user7304253 don't ever do `sudo npm` anything `EVER` – Zach_is_my_name Mar 01 '20 at 02:25
  • another day another reason to hate node – Bawantha Jan 10 '23 at 09:28

16 Answers16

261

"A requires a peer of B but none was installed". Consider it as "A requires one of B's peers but that peer was not installed and we're not telling you which of B's peers you need."

The automatic installation of peer dependencies was explicitly removed with npm 3.

NPM Blog

Release notes of v3

So you cannot install peer dependencies automatically with npm 3 and upwards.

Updated Solution:

Use following for each peer dependency to install that and remove the error

npm install --save-dev xxxxx

Deprecated Solution:

  1. You can use npm-install-peers to find and install required peer dependencies.

    npm install -g npm-install-peers

    npm-install-peers

  2. If you are getting this error after updating any package's version then remove node_modules directory and reinstall packages by npm install or npm cache clean and npm install.

Community
  • 1
  • 1
Ridham Tarpara
  • 5,970
  • 4
  • 19
  • 39
  • 26
    I am debugging the same issue as the OP and npm-install-peers returns only `This package doesn't seem to have any peerDependencies` – Lucas Gonze Mar 13 '18 at 18:15
  • need to check as I have been using this for a while – Ridham Tarpara Mar 14 '18 at 08:10
  • 14
    For future readers, this is not the correct solution, because `npm-install-peers` will only install **direct** peer dependencies, not peer dependencies of your dependencies. See their linked github page. – pushkin Jan 18 '19 at 18:14
  • 'npm cache clean' does not work straight forward. It will show errors and reference to sth. like 'npm install --cache /tmp/empty-cache'! Also 'npm cache verify' does not unqily tell 'ok' or 'error' but states what it did and not what was the outcome. – Dirk Schumacher Feb 05 '19 at 11:00
  • 3
    What does `--save-dev` do? – naught101 Apr 23 '19 at 04:50
  • @naught101 it saves dependencies as a development dependency in package.json – Ridham Tarpara Apr 23 '19 at 07:30
  • 11
    "...to install that and remove the error" seems incorrect english. It's also unclear how "xxxxx" relates to `A` and `B`. – Marc-André Lafortune Oct 06 '19 at 05:52
  • Is 'npm install --save-dev peers' the correct solution? – Cecilia Nov 14 '19 at 22:27
  • Funny trivia: The quote is erroneously copied from comments of [this answer](https://stackoverflow.com/a/35207983/985454). It should rather be "**_X requires the peer, Y, but Y was not installed_**" – Qwerty Feb 10 '20 at 14:26
  • I got this when I run `npm cache clean` - `As of npm@5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use 'npm cache verify' instead.` – Sylvester Loreto May 01 '20 at 11:48
  • 1
    $ npm-install-peers -bash: npm-install-peers: command not found – John Smith Oct 17 '20 at 19:18
  • 1
    What about if the required peer dependency is for instance React? You can't install React package as a DEV dependency... – Alex Dec 21 '21 at 13:40
245

For each error of the form:

npm WARN {something} requires a peer of {other thing} but none is installed. You must install peer dependencies yourself.

You should:

$ npm install --save-dev "{other thing}"

Note: The quotes are needed if the {other thing} has spaces, like in this example:

npm WARN rollup-plugin-uglify@6.0.3 requires a peer of rollup@>=0.66.0 <2 but none was installed.

Resolved with:

$ npm install --save-dev "rollup@>=0.66.0 <2"
Marc-André Lafortune
  • 78,216
  • 16
  • 166
  • 166
  • 16
    BTW what does '--save-dev' do? – Gabriel Fair Jan 12 '20 at 20:37
  • 13
    `--save-dev` saves the dependency as a *development dependency* to your `package.json` - [npm doc](https://docs.npmjs.com/specifying-dependencies-and-devdependencies-in-a-package-json-file#adding-dependencies-to-a-packagejson-file-from-the-command-line) – Yuri Feb 11 '20 at 14:56
  • 44
    There still seems to be lots of confusion around this. It'd be _really_ helpful if NPM would output the suggested command to install the missing peer dependency. – pdoherty926 Mar 12 '20 at 19:16
  • 1
    Is it possible to install `{other thing}` globally? I don't use local `package.json` files, only global installs. – Markus Laire Apr 17 '20 at 13:40
  • 17
    While this is arguably the same answer as others, it is the only one which clearly explains WHAT is to be replaced into the area other answers just list as "xxxxx". Thank you for that clarity. – Dewi Morgan Jan 24 '21 at 17:54
  • perfect solution. If the warning is about react-native version>xyx, that does not need to be install, but everything else needs to be install explicity. In my case it was only one library that was missing depedencies. – TheTechGuy Jun 15 '21 at 23:54
  • 5
    This worked but left me in a loop. When I install @angular/core@12.2.5, I then get "requires @angular/core@12.0.0" for some packages. Reasonably enough if I install @angular/core@12.0.0 I get "requires @angular/core@12.2.5". There are so many quirks in some dependency chains I could happily throw the whole lot overboard – Rob Von Nesselrode Sep 09 '21 at 20:13
44

The accepted answer of using npm-install-peers did not work, nor removing node_modules and rebuilding. The answer to run

npm install --save-dev @xxxxx/xxxxx@latest

for each one, with the xxxxx referring to the exact text in the peer warning, worked. I only had four warnings, if I had a dozen or more as in the question, it might be a good idea to script the commands.

Clearhat
  • 487
  • 4
  • 2
  • 18
    `package@latest` is the way down the rabbit hole – Trash Can Sep 10 '18 at 22:45
  • 25
    Why `--save-dev`? Wouldn't that add the peerDependency as a devDependency in package.json? – Fabian Lauer Dec 19 '18 at 10:55
  • 1
    @FabianLauer I think the point is that by adding them to devDependencies, the next person who runs `npm install` will get the peer dependencies without having to manually install them. Not sure how kosher that is though – pushkin Jan 18 '19 at 17:56
  • 2
    Why not save it? If a dev dependency is missing a required package this should be added and saved into devDependencies to ensure next install by developer/CI will have the same node modules available. – perry Feb 14 '19 at 21:55
  • 9
    please be more explicit in "xxxxx referring to the exact text in the peer warning" `npm WARN ABC requires a peer of XYZ@VER but none is installed. You must install peer dependencies yourself.`, should we use ABC, XYZ or other part of the warning? – serge Feb 18 '19 at 16:43
  • 6
    @Serge i used the equivalent of `XYZ@VER` from your example and it worked for me – MoralCode Feb 27 '19 at 05:24
  • 6
    Saving to dev dependencies means it's only used during development. Angular core is definitely not a dev dependency, it's a production dependency. – Nick Gallimore Mar 18 '20 at 18:28
  • 1
    Ditto @FabianLauer. `bootstrap@4.3.1 requires a peer of jquery@1.9.1` is clearly a production dependency, not a development support tool. Answers should also account for `--save` scenarios. – SushiGuy Jun 24 '20 at 16:22
  • 3
    Using @latest was a bad idea for me. I ended up with more items with version mismatches. I ended up using the version requested. If two different version of a package are required I checked to see if a different version is available on either end to resolve the mismatch. – JSWilson Apr 21 '21 at 20:05
18
npm install -g npm-install-peers

it will add all the missing peers and remove all the error

Hukmaram
  • 523
  • 5
  • 11
  • 8
    Only direct peer dependencies inside yours package.json will be installed from your project with this command. You'll still get warnings that all of your projects dependencies are missing peer dependencies. – Sam Mar 03 '20 at 04:48
  • 8
    This seems to be deprecated for the required solution now. Does not work anymore – Ujjwal Singh May 24 '20 at 13:48
10

I had a similar issue and solved after running these instructions!

npm install npm -g
npm install --save-dev @angular/cli@latest
npm install
npm start
NFT Master
  • 1,400
  • 12
  • 13
  • 5
    I suspect `npm install npm -g` is not a good idea for everyone as that would update `npm`, correct? – Gabriel Fair Jan 12 '20 at 20:38
  • 2
    Correct. And speaking of best practice, every node developer will end up using `nvm` someday. It can easily keep `npm` version up to date according to `node` version you intend to use. – NFT Master Jan 13 '20 at 04:19
  • 1
    Thanks a lot. I was setting up some project and executed `npm install -g` without thinking of repercussions of my actions.. this saved a lot of time. – Xonshiz Dec 30 '20 at 08:57
10

since npm7 was released you can now install automatically the Peer Dependencies. they make an algorithm to Ensure that a validly matching peer dependency is found at or above the peer-dependant's location in the node_modules tree.if that's the case then they add the peer dependencies correctly. you just need to install npm 7

npm i -g npm@7

find more a link

Azer8
  • 539
  • 8
  • 18
9

i had the same problem with react-firebase-file-uploader.

npm i {something} --legacy-peer-deps  #worked fine for me
Salim Nadji
  • 715
  • 5
  • 5
  • 2
    This should be the correct answer, although maybe the forwards slash should be a hash comment, unless *of course* you're accessing this through IRC. ```npm i --legacy-peer-deps``` worked for same question I had. – Tyeth Oct 17 '21 at 12:45
3

In my case following commands worked for me:

sudo npm cache clean --force
sudo npm install -g npm


sudo apt install libssl1.0-dev
sudo apt install nodejs-dev
sudo apt install node-gyp
sudo apt install npm

After that if you are facing "Cannot find module 'bcrypt' then for that you can resolve this one with below commands:

npm install node-gyp -g
npm install bcrypt -g
npm install bcrypt --save  

Hope it will work for you as well.

Jitendra
  • 3,135
  • 2
  • 26
  • 42
3

Same problem with AWS CDK, but for me it helped to rm -rf node_modules before npm install.

Also make sure that all aws-cdk components are in the same version.

rantoniuk
  • 1,083
  • 12
  • 18
2

I don't know if someone tried this new package:

npm install -g install-peerdeps

This is the alternative of npm install -g npm-install-peers

Link of the source: https://www.npmjs.com/package/install-peerdeps

Sahil Patel
  • 1,570
  • 2
  • 15
  • 34
1

total edge case here: I had this issue installing an Arch AUR PKGBUILD file manually. In my case I needed to delete the 'pkg', 'src' and 'node_modules' folders, then it built fine without this npm error.

Elijah Lynn
  • 12,272
  • 10
  • 61
  • 91
0

I would suggest to use this tool called depcheck. According with the author definition:

Depcheck is a tool for analyzing the dependencies in a project to see: how each dependency is used, which dependencies are useless, and which dependencies are missing from package.json

https://www.npmjs.com/package/depcheck

Mauro Bilotti
  • 5,628
  • 4
  • 44
  • 65
-1

You need to only depend on one major version of angular, so update all modules depending on angular 2.x :

  • update @angular/flex-layout to ^2.0.0-beta.9
  • update @angular/material to ^2.0.0-beta.12
  • update angularfire2 to ^4.0.0-rc.2
  • update zone.js to ^0.8.18
  • update webpack to ^3.8.1
  • add @angular/cdk@2.0.0-beta.12 (required for @angular/material)
  • replace angular2-google-maps by @agm/core@1.0.0-beta.1 (new name)
Gabriel Bleu
  • 9,703
  • 2
  • 30
  • 43
  • 7
    Could you expound and give a generalized solution? I have a similar issue and would like not to "Ignore warnings", as recommended in comments above. What configuration is needed to not show this type of warning? Note: for my project is `npm WARN react-test-renderer@16.1.1 requires a peer of react@^16.0.0 but none is installed...` and yes I do have the required peer installed. Is this is an issue with my project or an issue with the react-test-renderer project? Or do I need to find all peers and make their versions align somehow? – Matt Nov 22 '17 at 15:33
-1

Had the same issue installing angular material CDK:

npm install --save @angular/material @angular/cdk @angular/animations

Adding -dev like below worked for me:

npm install --save-dev @angular/material @angular/cdk @angular/animations
double-beep
  • 5,031
  • 17
  • 33
  • 41
Luckza
  • 29
  • 4
-1

Try installing multer using the following command. It worked for me.

npm i --save-dev @types/multer 
Udit
  • 129
  • 2
  • 6
-4
npm i [package-name] --force

use --force.

Mitesh K
  • 694
  • 1
  • 11
  • 24
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - [From Review](/review/low-quality-posts/29050060) – Majid Hajibaba May 25 '21 at 12:31
  • 4
    @majidhajibaba Why not? This doesn't look like a comment. This looks like an answer. If you think it's not a good one - downvote, don't delete. Please read [You're doing it wrong: A plea for sanity in the Low Quality Posts queue](https://meta.stackoverflow.com/q/287563/6045800) – Tomerikoo May 25 '21 at 12:51