npm警告…需要与……但是没有安装。您必须自己安装对等依赖项

我试图运行一个从github下载的项目。不幸的是,在npm install期间显示了以下警告。我尝试基于问题更改版本。但是,我遇到了一个问题,因为一些包需要其他包的多个版本。考虑这两行:

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.

因此,安装一些包会导致依赖项列表大幅增加。

有人有办法吗?

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.

下面是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返回(我只粘贴了开头和结尾):

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.
614489 次浏览

你只需要依赖angular的一个主要版本,所以要根据angular 2更新所有模块。x:

  • 更新@angular/flex-layout到^2.0.0-beta.9
  • 更新@angular/material到^2.0.0-beta.12
  • 更新angularfire2到^4.0.0-rc.2
  • 更新zone.js到^0.8.18
  • 更新webpack到^3.8.1
  • 添加@angular/cdk@2.0.0-beta.12 (@angular/material需要)
  • 将angular2-google-maps替换为@agm/core@1.0.0-beta.1(新名称)

"A需要B的对等体,但没有安装"。把它当做“A” 需要B的一个对等点,但是那个对等点没有安装,我们 没有告诉你你需要B的哪些同事。" < / p >

npm 3明确地删除了对等依赖的自动安装。

NPM Blog

v3版本说明书 . > . > v3版本说明书

所以在npm 3及以上版本中,你不能自动安装对等依赖项。

更新的解决方案:

对每个对等依赖项使用以下命令来安装并删除错误

npm install --save-dev xxxxx

弃用的解决方案:

  1. 你可以使用npm-install-peers来查找和安装所需的对等依赖项。

    npm install -g npm-install-peers

    npm-install-peers < / p >

  2. 如果在更新任何包的版本后出现此错误,则删除node_modules目录并通过npm installnpm cache cleannpm install重新安装包。

我有一个类似的问题,并解决后运行这些指令!

npm install npm -g
npm install --save-dev @angular/cli@latest
npm install
npm start

使用npm-install-peers不能工作,也不能删除node_modules并重新构建。逃跑的答案

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

对于每一个,XXXXX都是指同行警告中的确切文本。我只有四个警告,如果我像问题中那样有十几个或更多警告,那么编写脚本命令可能是个好主意。

总边缘情况在这里:我有这个问题安装Arch AUR PKGBUILD文件手动。在我的情况下,我需要删除“pkg”,“src”和“node_modules”文件夹,然后它构建良好,没有这个npm错误。

在安装角材质CDK时也遇到了同样的问题:

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

像下面这样添加-dev对我有用:

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

对于表单中的每一个错误:

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

你应该:

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

请注意:如果{other thing}有空格,就需要引号,就像下面的例子:

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

解决:

$ npm install --save-dev "rollup@>=0.66.0 <2"
npm install -g npm-install-peers

它将添加所有缺失的对等体并删除所有错误

在我的案例中,以下命令对我很有效:

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

之后,如果你遇到“无法找到模块'bcrypt'”,那么你可以用下面的命令来解决这个问题:

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

希望这对你也有用。

npm i -D @angular/material @angular/cdk @angular/animations

我在react-firebase-file-uploader上也遇到了同样的问题。

npm i {something} --legacy-peer-deps  #worked fine for me

AWS CDK也有同样的问题,但对我来说,在npm install之前rm -rf node_modules是有帮助的。

还要确保所有aws-cdk组件的版本相同。

我不知道是否有人尝试过这个新包:

npm install -g install-peerdeps

这是npm install -g npm-install-peers的替代

源代码的链接:https://www.npmjs.com/package/install-peerdeps

npm i [package-name] --force

——使用武力。

因为npm7发布了,你现在可以自动安装对等依赖项了。 他们制定了一种算法,以确保在node_modules树中对等依赖项的位置或上面找到一个有效匹配的对等依赖项。如果是这样,那么他们正确地添加了对等依赖项。 你只需要安装NPM 7

npm i -g npm@7

找到更多一个链接

尝试使用以下命令安装multer。这对我很管用。

npm i --save-dev @types/multer

我建议使用这个名为depcheck的工具。根据作者定义:

Depcheck是一个分析项目依赖关系的工具,可以看到: 如何使用每个依赖项,哪些依赖项是无用的,哪些是无用的 package.json

中缺少依赖项

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