0

npm install --legacy-peer-deps 不能解决问题

设置 apollo-angular 时 CLI 中断,如果我手动尝试,我会得到同样的错误。在一个新项目上试了一下,还是不行。您是否可以在以下步骤中看到:

  1. ng new apollo-angular-test
  2. ...安装后
  3. cd apollo-angular-test

错误:

> Error: npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve
> dependency tree
>      0 verbose cli [ 0 verbose cli   'C:\\Program Files\\nodejs\\node.exe', 0 verbose cli  
> 'C:\\Users\\Owner\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
> 0 verbose cli   'install', 0 verbose cli   'apollo-angular@2.6.0', 0
> verbose cli   '--quiet' 0 verbose cli ] 1 info using npm@8.1.4 2 info
> using node@v14.15.1 3 timing npm:load:whichnode Completed in 1ms 4
> timing config:load:defaults Completed in 1ms 5 timing
> config:load:file:C:\Users\Owner\AppData\Roaming\npm\node_modules\npm\npmrc
> Completed in 4ms 6 timing config:load:builtin Completed in 4ms 7
> timing config:load:cli Completed in 3ms 8 timing config:load:env
> Completed in 1ms 9 timing
> config:load:file:D:\web-projects\apollo-angular-test\.npmrc Completed
> in 1ms 10 timing config:load:project Completed in 3ms 11 timing
> config:load:file:C:\Users\Owner\.npmrc Completed in 1ms 12 timing
> config:load:user Completed in 1ms 13 timing
> config:load:file:C:\Users\Owner\AppData\Roaming\npm\etc\npmrc
> Completed in 1ms 14 timing config:load:global Completed in 1ms 15
> timing config:load:validate Completed in 0ms 16 timing
> config:load:credentials Completed in 1ms 17 timing config:load:setEnvs
> Completed in 0ms 18 timing config:load Completed in 15ms 19 timing
> npm:load:configload Completed in 16ms 20 timing npm:load:setTitle
> Completed in 0ms 21 timing npm:load:setupLog Completed in 0ms 22
> timing config:load:flatten Completed in 3ms 23 timing
> npm:load:cleanupLog Completed in 2ms 24 timing npm:load:configScope
> Completed in 0ms 25 timing npm:load:projectScope Completed in 2ms 26
> timing npm:load Completed in 24ms 27 timing arborist:ctor Completed in
> 1ms 28 timing idealTree:init Completed in 571ms 29 timing
> idealTree:userRequests Completed in 7ms 30 silly idealTree buildDeps
> 31 silly fetch manifest apollo-angular@2.6.0 32 timing arborist:ctor
> Completed in 0ms 33 http fetch GET 200
> https://registry.npmjs.org/apollo-angular 1067ms (cache revalidated)
> 34 silly fetch manifest @angular/core@~13.0.0 35 http fetch GET 200
> https://registry.npmjs.org/@angular%2fcore 14ms (cache hit) 36 silly
> fetch manifest @angular/core@^6.1.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 ||
> ^10.0.0 || ^11.0.0 || ^12.0.0 37 silly fetch manifest rxjs@~7.4.0 38
> http fetch GET 200 https://registry.npmjs.org/rxjs 8ms (cache hit) 39
> silly fetch manifest zone.js@~0.11.4 40 http fetch GET 200
> https://registry.npmjs.org/zone.js 6ms (cache hit) 41 timing idealTree
> Completed in 1715ms 42 timing command:install Completed in 1721ms 43
> verbose stack Error: unable to resolve dependency tree 43 verbose
> stack     at Arborist.[failPeerConflict]
> (C:\Users\Owner\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1356:25)
> 43 verbose stack     at Arborist.[loadPeerSet]
> (C:\Users\Owner\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1322:34)
> 43 verbose stack     at async Arborist.[buildDepStep]
> (C:\Users\Owner\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:930:11)
> 43 verbose stack     at async Arborist.buildIdealTree
> (C:\Users\Owner\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:216:7)
> 43 verbose stack     at async Promise.all (index 1) 43 verbose stack  
> at async Arborist.reify
> (C:\Users\Owner\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:149:5)
> 43 verbose stack     at async Install.exec
> (C:\Users\Owner\AppData\Roaming\npm\node_modules\npm\lib\commands\install.js:157:5)
> 43 verbose stack     at async module.exports
> (C:\Users\Owner\AppData\Roaming\npm\node_modules\npm\lib\cli.js:65:5)
> 44 verbose cwd D:\web-projects\apollo-angular-test 45 verbose
> Windows_NT 10.0.17134 46 verbose argv "C:\\Program
> Files\\nodejs\\node.exe"
> "C:\\Users\\Owner\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js"
> "install" "apollo-angular@2.6.0" "--quiet" 47 verbose node v14.15.1 48
> verbose npm  v8.1.4 49 error code ERESOLVE 50 error ERESOLVE unable to
> resolve dependency tree 51 error 52 error While resolving:
> apollo-angular-test@0.0.0 52 error Found: @angular/core@13.0.2 52
> error node_modules/@angular/core 52 error   @angular/core@"~13.0.0"
> from the root project 52 error 52 error Could not resolve dependency:
> 52 error peer @angular/core@"^6.1.0 || ^7.i0.0 || ^8.0.0 || ^9.0.0 ||
> ^10.0.0 || ^11.0.0 || ^12.0.0" from apollo-angular@2.6.0 52 error
> node_modules/apollo-angular 52 error   apollo-angular@"2.6.0" from the
> root project 52 error 52 error Fix the upstream dependency conflict,
> or retry 52 error this command with --force, or --legacy-peer-deps 52
> error to accept an incorrect (and potentially broken) dependency
> resolution. 52 error 52 error See
> C:\Users\Owner\AppData\Local\npm-cache\eresolve-report.txt for a full
> report. 53 verbose exit 1

包.json。您会注意到这是一个干净的安装。

{
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~13.0.0",
    "@angular/common": "~13.0.0",
    "@angular/compiler": "~13.0.0",
    "@angular/core": "~13.0.0",
    "@angular/forms": "~13.0.0",
    "@angular/platform-browser": "~13.0.0",
    "@angular/platform-browser-dynamic": "~13.0.0",
    "@angular/router": "~13.0.0",
    "reset-css": "^5.0.1",
    "rxjs": "~7.4.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~13.0.2",
    "@angular/cli": "~13.0.2",
    "@angular/compiler-cli": "~13.0.0",
    "@types/jasmine": "~3.10.0",
    "@types/node": "^12.20.37",
    "jasmine-core": "~3.10.0",
    "karma": "~6.3.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "~1.7.0",
    "typescript": "~4.4.3"
  }
}
4

0 回答 0