我不确定在升级节点模块时修复 devDependency 错误所采取的步骤是否正确。我列出了以下步骤以及我为尝试纠正它而采取的行动。
(编辑)-我应该删除我的node_modules文件夹然后运行
>npm install
吗?我已将当前使用的保存在我的存储库中。
我运行
>ncu -u
来检查和更新 package.js 中的节点模块(下图),然后运行 >npm install
来更新,但 devDependency 中出现错误。请参阅底部图片。
这是我要升级的 npm 模块。我主要是为了升级到 Angular 17。
➜ client git:(master) ncu -u
Upgrading /Users/charles/yogabandy2020/client/package.json
[====================] 58/58 100%
@angular-devkit/build-angular ^16.2.14 → ^17.3.4
@angular/animations ^16.2.12 → ^17.3.4
@angular/cdk ^15.1.2 → ^17.3.4
@angular/cli ^16.2.14 → ^17.3.4
@angular/common ^16.2.12 → ^17.3.4
@angular/compiler ^16.2.12 → ^17.3.4
@angular/compiler-cli ^16.2.12 → ^17.3.4
@angular/core ^16.2.12 → ^17.3.4
@angular/forms ^16.2.12 → ^17.3.4
@angular/google-maps ^15.2.9 → ^17.3.4
@angular/localize ^16.2.12 → ^17.3.4
@angular/platform-browser ^16.2.12 → ^17.3.4
@angular/platform-browser-dynamic ^16.2.12 → ^17.3.4
@angular/router ^16.2.12 → ^17.3.4
@auth0/angular-jwt ^5.1.2 → ^5.2.0
@cloudinary/ng ^1.11.2 → ^2.0.2
@cloudinary/url-gen ^1.9.2 → ^1.19.0
@fortawesome/fontawesome-free ^6.2.1 → ^6.5.2
@stripe/stripe-js ^1.48.0 → ^3.3.0
@types/jasmine ^4.3.1 → ^5.1.4
@types/jasminewd2 ^2.0.10 → ^2.0.13
@types/lodash ^4.14.191 → ^4.17.0
@types/node ^18.11.18 → ^20.12.7
@typescript-eslint/eslint-plugin ^5.49.0 → ^7.6.0
@typescript-eslint/parser ^5.49.0 → ^7.6.0
bootstrap ^5.2.3 → ^5.3.3
eslint ^8.32.0 → ^9.0.0
eslint-plugin-html ^7.1.0 → ^8.1.0
heic2any ^0.0.3 → ^0.0.4
jasmine-core ~4.5.0 → ~5.1.2
karma ~6.4.1 → ~6.4.3
karma-chrome-launcher ~3.1.1 → ~3.2.0
karma-jasmine-html-reporter ^2.0.0 → ^2.1.0
luxon ^3.2.1 → ^3.4.4
ng-gallery ^8.0.2 → ^11.0.0
ngx-bootstrap ^10.2.0 → ^12.0.0
ngx-image-cropper ^6.3.2 → ^7.2.1
ngx-mask ^15.0.3 → ^17.0.7
ngx-stripe ^15.5.0 → ^17.2.0
rxjs ~7.8.0 → ~7.8.1
swiper ^8.4.7 → ^11.1.1
ts-node ~10.9.1 → ~10.9.2
tslib ^2.5.0 → ^2.6.2
typescript ^4.9.4 → ^5.4.5
zone.js ^0.13.0 → ^0.14.4
Run npm install to install new versions.
➜ client git:(master) ✗
这是我运行后修改后的 npm package.js 文件
>ncu -u
{
"name": "client",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^17.3.4",
"@angular/cdk": "^17.3.4",
"@angular/common": "^17.3.4",
"@angular/compiler": "^17.3.4",
"@angular/core": "^17.3.4",
"@angular/forms": "^17.3.4",
"@angular/google-maps": "^17.3.4",
"@angular/localize": "^17.3.4",
"@angular/platform-browser": "^17.3.4",
"@angular/platform-browser-dynamic": "^17.3.4",
"@angular/router": "^17.3.4",
"@auth0/angular-jwt": "^5.2.0",
"@cloudinary/ng": "^2.0.2",
"@cloudinary/url-gen": "^1.19.0",
"@fortawesome/fontawesome-free": "^6.5.2",
"@ngneat/content-loader": "^7.0.0",
"@stripe/stripe-js": "^3.3.0",
"bootstrap": "^5.3.3",
"hammerjs": "^2.0.8",
"heic2any": "^0.0.4",
"image-filters": "^1.0.1",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"luxon": "^3.4.4",
"ng-gallery": "^11.0.0",
"ngx-bootstrap": "^12.0.0",
"ngx-image-cropper": "^7.2.1",
"ngx-mask": "^17.0.7",
"ngx-stripe": "^17.2.0",
"ngx-webcam": "^0.4.1",
"rxjs": "~7.8.1",
"tslib": "^2.6.2",
"tz-lookup": "^6.1.25",
"zone.js": "^0.14.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "^17.3.4",
"@angular/cli": "^17.3.4",
"@angular/compiler-cli": "^17.3.4",
"@types/jasmine": "^5.1.4",
"@types/jasminewd2": "^2.0.13",
"@types/lodash": "^4.17.0",
"@types/node": "^20.12.7",
"@typescript-eslint/eslint-plugin": "^7.6.0",
"@typescript-eslint/parser": "^7.6.0",
"codelyzer": "^6.0.2",
"eslint": "^9.0.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-html": "^8.1.0",
"jasmine-core": "~5.1.2",
"jasmine-spec-reporter": "~7.0.0",
"karma": "~6.4.3",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage-istanbul-reporter": "~3.0.3",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "^2.1.0",
"protractor": "~7.0.0",
"swiper": "^11.1.1",
"ts-node": "~10.9.2",
"typescript": "^5.4.5"
}
}
接下来我运行了
>npm install
,我在下面看到了这个错误,所以我改变了
"eslint": "^9.0.0"
到 "eslint": "^8.56.0",
这似乎解决了这个错误。
➜ client git:(master) ✗ npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/eslint
npm ERR! dev eslint@"^9.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer eslint@"^8.56.0" from @typescript-eslint/[email protected]
npm ERR! node_modules/@typescript-eslint/parser
npm ERR! dev @typescript-eslint/parser@"^7.6.0" from the root project
npm ERR! peer @typescript-eslint/parser@"^7.0.0" from @typescript-eslint/[email protected]
npm ERR! node_modules/@typescript-eslint/eslint-plugin
npm ERR! dev @typescript-eslint/eslint-plugin@"^7.6.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! /Users/charles/.npm/_logs/2024-04-13T01_02_45_312Z-eresolve-report.txt
npm ERR! A complete log of this run can be found in: /Users/charles/.npm/_logs/2024-04-13T01_02_45_312Z-debug-0.log
➜ client git:(master) ✗
然后我再次运行
>npm install
并看到下面的错误,因此我将 "@angular/compiler-cli": "^17.3.4",
更改为 "@angular/compiler-cli": "^17.0.0",
但这似乎并没有修复错误。
➜ client git:(master) ✗ npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: @angular-devkit/[email protected]
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! dev @angular-devkit/build-angular@"^17.3.4" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! dev @angular-devkit/build-angular@"^17.3.4" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/[email protected]
npm ERR! node_modules/@angular/compiler-cli
npm ERR! peer @angular/compiler-cli@"^17.0.0" from @angular-devkit/[email protected]
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! dev @angular-devkit/build-angular@"^17.3.4" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! /Users/charles/.npm/_logs/2024-04-13T01_27_59_149Z-eresolve-report.txt
npm ERR! A complete log of this run can be found in: /Users/charles/.npm/_logs/2024-04-13T01_27_59_149Z-debug-0.log
➜ client git:(master) ✗
运行 ncu -u 后,使用 npm install 更新您的 npm 软件包。
您与 eslint 包有冲突 将 "eslint": "^9.0.0" 更改为 "eslint": "^8.56.0"
将“@Angular-devkit/build-Angular”:“^17.3.4”更改为“@Angular-devkit/build- 角度”:“^17.0.0”。
进行此更改后,再次运行 npm install。
如果上述步骤失败,您可以使用以下命令重试:npm install --legacy-peer-deps
我认为做这些事情就能解决问题