我之前曾嘗試從 tslint 轉換為 eslint,但我從未通過ng add @angular-eslint/schematics
因為我使用的是舊的 Angular 版本(8),我想我會等到更新,而我現在剛剛更新到最新的(14)
現在我已經更新了,我仍然無法運行上面的。我明白了。。
$ ng add @angular-eslint/schematics
Skipping installation: Package already installed
All @angular-eslint dependencies have been successfully installed ??
Please see https://github.com/angular-eslint/angular-eslint for how to add ESLint configuration to your project.
UPDATE package.json (7380 bytes)
? Installing packages (npm)...npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: myApp@undefined
npm WARN Found: [email protected]
npm WARN node_modules/eslint
npm WARN dev eslint@"^8.17.0" from the root project
npm WARN 15 more (@angular-eslint/builder, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer eslint@"^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0" from [email protected]
npm WARN node_modules/eslint-plugin-import
npm WARN dev eslint-plugin-import@"2.22.1" from the root project
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: myApp@undefined
npm WARN Found: [email protected]
npm WARN node_modules/eslint
npm WARN dev eslint@"^8.17.0" from the root project
npm WARN 15 more (@angular-eslint/builder, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer eslint@"^6.0.0 || ^7.0.0" from [email protected]
npm WARN node_modules/eslint-plugin-jsdoc
npm WARN dev eslint-plugin-jsdoc@"30.7.6" from the root project
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @ngrx/[email protected]
npm ERR! Found: @angular/[email protected]
npm ERR! node_modules/@angular/core
npm ERR! @angular/core@"^14.0.2" from the root project
npm ERR! peer @angular/core@"14.0.2" from @angular/[email protected]
npm ERR! node_modules/@angular/animations
npm ERR! @angular/animations@"^14.0.2" from the root project
npm ERR! peerOptional @angular/animations@"14.0.2" from @angular/[email protected]
npm ERR! node_modules/@angular/platform-browser
npm ERR! @angular/platform-browser@"^14.0.2" from the root project
npm ERR! 3 more (@angular/forms, @angular/platform-browser-dynamic, @angular/router)
npm ERR! 12 more (@angular/common, @angular/compiler, @angular/forms, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/core@"^13.0.0" from @ngrx/[email protected]
npm ERR! node_modules/@ngrx/effects
npm ERR! @ngrx/effects@"^13.2.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/[email protected]
npm ERR! node_modules/@angular/core
npm ERR! peer @angular/core@"^13.0.0" from @ngrx/[email protected]
npm ERR! node_modules/@ngrx/effects
npm ERR! @ngrx/effects@"^13.2.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! See C:\Users\peter\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\peter\AppData\Local\npm-cache\_logs\2022-06-20T09_30_09_455Z-debug-0.log
? Package install failed, see above.
The Schematic workflow failed. See above.
在源代碼中,如果我創建一個錯誤,我仍然看到它正在tslint拾取它
我的 Angular 開發依賴項是
"devDependencies": {
"@angular-devkit/architect": "^0.1400.2",
"@angular-devkit/build-angular": "^14.0.2",
"@angular-devkit/core": "^14.0.2",
"@angular-devkit/schematics": "^14.0.2",
"@angular-eslint/builder": "14.0.0-alpha.3",
"@angular-eslint/eslint-plugin": "14.0.0-alpha.3",
"@angular-eslint/eslint-plugin-template": "14.0.0-alpha.3",
"@angular-eslint/schematics": "14.0.0-alpha.3",
"@angular-eslint/template-parser": "14.0.0-alpha.3",
"@angular/cli": "^14.0.2",
"@angular/compiler": "^14.0.2",
"@angular/compiler-cli": "^14.0.2",
"@angular/language-service": "^14.0.2",
"@ionic/angular-toolkit": "^2.0.0",
所以,我弄壞了一些東西,想知道如何解決這個問題并更新

uj5u.com熱心網友回復:
ng add運行命令后安裝依賴項時出現的錯誤來自@ngrx/effects。這個包需要 angular 13,但是你安裝了 angular 14。@ngrx/effects 似乎還不支持 angular 14,請檢查此版本14.0.0-rc.0。
還要檢查你的 vscode 插件,確保禁用tslint并安裝/啟用eslint。我還假設您轉換了 lint 配置。
如果您同時安裝了兩個插件,它會不時拋出奇怪的錯誤
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/493838.html
