简体   繁体   English

How do I install the right version of @angular-eslint/schematic to match my angular-compiler?

[英]How do I install the right version of @angular-eslint/schematic to match my angular-compiler?

I have these dependencies defined in my package.json file

"@angular/compiler": "^13.2.6",
"@angular/core": "^13.2.6",

I would like to get "ng lint" to run, but evidently I need to run a migration so I ran

$ ng add @angular-eslint/schematics
Your global Angular CLI version (14.0.5) is greater than your local version (13.2.6). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
ℹ Using package manager: npm
✔ Found compatible package version: @angular-eslint/schematics@13.5.0.
✔ Package information loaded.

The package @angular-eslint/schematics@13.5.0 will be installed and executed.
Would you like to proceed? Yes
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @angular/compiler-cli@13.2.7
npm ERR! Found: @angular/compiler@13.3.0
npm ERR! node_modules/@angular/compiler
npm ERR!   peer @angular/compiler@"13.3.0" from @angular/platform-browser-dynamic@13.3.0
npm ERR!   node_modules/@angular/platform-browser-dynamic
npm ERR!     @angular/platform-browser-dynamic@"^13.2.6" from the root project
npm ERR!   @angular/compiler@"^13.2.6" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/compiler@"13.2.7" from @angular/compiler-cli@13.2.7
npm ERR! node_modules/@angular/compiler-cli
npm ERR!   peer @angular/compiler-cli@"^13.0.0" from @angular-devkit/build-angular@13.2.6
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"~13.2.5" from the root project
npm ERR!   peer @angular/compiler-cli@"^13.0.0" from @ngtools/webpack@13.2.6
npm ERR!   node_modules/@ngtools/webpack
npm ERR!     @ngtools/webpack@"13.2.6" from @angular-devkit/build-angular@13.2.6
npm ERR!     node_modules/@angular-devkit/build-angular
npm ERR!       dev @angular-devkit/build-angular@"~13.2.5" from the root project
npm ERR!   1 more (the root project)
npm ERR!
npm ERR! Conflicting peer dependency: @angular/compiler@13.2.7
npm ERR! node_modules/@angular/compiler
npm ERR!   peer @angular/compiler@"13.2.7" from @angular/compiler-cli@13.2.7
npm ERR!   node_modules/@angular/compiler-cli
npm ERR!     peer @angular/compiler-cli@"^13.0.0" from @angular-devkit/build-angular@13.2.6
npm ERR!     node_modules/@angular-devkit/build-angular
npm ERR!       dev @angular-devkit/build-angular@"~13.2.5" from the root project
npm ERR!     peer @angular/compiler-cli@"^13.0.0" from @ngtools/webpack@13.2.6
npm ERR!     node_modules/@ngtools/webpack
npm ERR!       @ngtools/webpack@"13.2.6" from @angular-devkit/build-angular@13.2.6
npm ERR!       node_modules/@angular-devkit/build-angular
npm ERR!         dev @angular-devkit/build-angular@"~13.2.5" from the root project
npm ERR!     1 more (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\mydemouser\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\mydemouser\AppData\Local\npm-cache\_logs\2022-07-15T13_41_12_993Z-debug-0.log
✖ Package install failed, see above.

How do I save teh right install the right version of the tool to match the compiler I'm using?

Edit: In response to the answer given, this was the output after running the command again when clearing out package-lock and node_modules

> ng add @angular-eslint/schematics
i Using package manager: npm
√ Found compatible package version: @angular-eslint/schematics@1.0.0.
√ Package information loaded.

The package @angular-eslint/schematics@1.0.0 will be installed and executed.
Would you like to proceed? Yes
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: my-project@0.0.0
npm ERR! Found: @angular/common@13.3.11
npm ERR! node_modules/@angular/common
npm ERR!   @angular/common@"^13.2.6" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^9.0.0" from ng-http-loader@7.0.0
npm ERR! node_modules/ng-http-loader
npm ERR!   ng-http-loader@"^7.0.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\myuser\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\myuser\AppData\Local\npm-cache\_logs\2022-07-20T16_52_29_241Z-debug-0.log
× Packages installation failed, see above.

Edit 2: In response to @Alex's answer, I got this error after upgrading the dependency

> ng add @angular-eslint/schematics
Your global Angular CLI version (14.0.5) is greater than your local version (13.2.6). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
i Using package manager: npm
√ Found compatible package version: @angular-eslint/schematics@13.5.0.
√ Package information loaded.

The package @angular-eslint/schematics@13.5.0 will be installed and executed.
Would you like to proceed? Yes
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @angular/compiler-cli@13.2.7
npm ERR! Found: @angular/compiler@13.3.0
npm ERR! node_modules/@angular/compiler
npm ERR!   peer @angular/compiler@"13.3.0" from @angular/platform-browser-dynamic@13.3.0
npm ERR!   node_modules/@angular/platform-browser-dynamic
npm ERR!     @angular/platform-browser-dynamic@"^13.2.6" from the root project
npm ERR!   @angular/compiler@"^13.2.6" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/compiler@"13.2.7" from @angular/compiler-cli@13.2.7
npm ERR! node_modules/@angular/compiler-cli
npm ERR!   peer @angular/compiler-cli@"^13.0.0" from @angular-devkit/build-angular@13.2.6
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"~13.2.5" from the root project
npm ERR!   peer @angular/compiler-cli@"^13.0.0" from @ngtools/webpack@13.2.6
npm ERR!   node_modules/@ngtools/webpack
npm ERR!     @ngtools/webpack@"13.2.6" from @angular-devkit/build-angular@13.2.6
npm ERR!     node_modules/@angular-devkit/build-angular
npm ERR!       dev @angular-devkit/build-angular@"~13.2.5" from the root project
npm ERR!   1 more (the root project)
npm ERR!
npm ERR! Conflicting peer dependency: @angular/compiler@13.2.7
npm ERR! node_modules/@angular/compiler
npm ERR!   peer @angular/compiler@"13.2.7" from @angular/compiler-cli@13.2.7
npm ERR!   node_modules/@angular/compiler-cli
npm ERR!     peer @angular/compiler-cli@"^13.0.0" from @angular-devkit/build-angular@13.2.6
npm ERR!     node_modules/@angular-devkit/build-angular
npm ERR!       dev @angular-devkit/build-angular@"~13.2.5" from the root project
npm ERR!     peer @angular/compiler-cli@"^13.0.0" from @ngtools/webpack@13.2.6
npm ERR!     node_modules/@ngtools/webpack
npm ERR!       @ngtools/webpack@"13.2.6" from @angular-devkit/build-angular@13.2.6
npm ERR!       node_modules/@angular-devkit/build-angular
npm ERR!         dev @angular-devkit/build-angular@"~13.2.5" from the root project
npm ERR!     1 more (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! A complete log of this run can be found in:

Edit 3: Here's the error I got from running @Mohammed.Kotkotly's answer ...

> ng add @angular-eslint/schematics@13.2.1
√ Package information loaded.

The package @angular-eslint/schematics@13.2.1 will be installed and executed.
Would you like to proceed? Yes
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @angular/compiler-cli@13.2.7
npm ERR! Found: @angular/compiler@13.3.0
npm ERR! node_modules/@angular/compiler
npm ERR!   peer @angular/compiler@"13.3.0" from @angular/platform-browser-dynamic@13.3.0
npm ERR!   node_modules/@angular/platform-browser-dynamic
npm ERR!     @angular/platform-browser-dynamic@"^13.2.6" from the root project
npm ERR!   @angular/compiler@"^13.2.6" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/compiler@"13.2.7" from @angular/compiler-cli@13.2.7
npm ERR! node_modules/@angular/compiler-cli
npm ERR!   peer @angular/compiler-cli@"^13.0.0" from @angular-devkit/build-angular@13.2.6
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"~13.2.5" from the root project
npm ERR!   peer @angular/compiler-cli@"^13.0.0" from @ngtools/webpack@13.2.6
npm ERR!   node_modules/@ngtools/webpack
npm ERR!     @ngtools/webpack@"13.2.6" from @angular-devkit/build-angular@13.2.6
npm ERR!     node_modules/@angular-devkit/build-angular
npm ERR!       dev @angular-devkit/build-angular@"~13.2.5" from the root project
npm ERR!   1 more (the root project)
npm ERR!
npm ERR! Conflicting peer dependency: @angular/compiler@13.2.7
npm ERR! node_modules/@angular/compiler
npm ERR!   peer @angular/compiler@"13.2.7" from @angular/compiler-cli@13.2.7
npm ERR!   node_modules/@angular/compiler-cli
npm ERR!     peer @angular/compiler-cli@"^13.0.0" from @angular-devkit/build-angular@13.2.6
npm ERR!     node_modules/@angular-devkit/build-angular
npm ERR!       dev @angular-devkit/build-angular@"~13.2.5" from the root project
npm ERR!     peer @angular/compiler-cli@"^13.0.0" from @ngtools/webpack@13.2.6
npm ERR!     node_modules/@ngtools/webpack
npm ERR!       @ngtools/webpack@"13.2.6" from @angular-devkit/build-angular@13.2.6
npm ERR!       node_modules/@angular-devkit/build-angular
npm ERR!         dev @angular-devkit/build-angular@"~13.2.5" from the root project
npm ERR!     1 more (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\dt236609\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:

       

Your new stacktrace explains your error.您的新堆栈跟踪解释了您的错误。 You have ng-http-loader@7.0.0 installed which is only compatible with Angular ^9.0.0 .您安装了ng-http-loader@7.0.0 ,它仅与 Angular ^9.0.0兼容。 Update ng-http loader to >=11.0.0.将 ng-http 加载器更新为 >=11.0.0。

The problem is due to compatibility, and according to Angular ESLint Publisher问题是由于兼容性,根据Angular ESLint Publisher

  • @angular-eslint packages at 12.xx and @angular/cli@12.xx are compatible 12.xx 和 @angular/cli@12.xx 的 @angular-eslint 包是兼容的
  • @angular-eslint packages at 13.xx and @angular/cli@13.xx are compatible 13.xx 和 @angular/cli@13.xx 的 @angular-eslint 包是兼容的
  • @angular-eslint packages at 14.xx and @angular/cli@14.xx are compatible 14.xx 和 @angular/cli@14.xx 的 @angular-eslint 包是兼容的
  • ...and so on... ...等等...

Try尝试

ng add @angular-eslint/schematics@13.2.1

This problem is sincerely not from Angular (nor the schematics linter) but with NPM.这个问题真诚地不是来自 Angular(也不是原理图 linter),而是来自 NPM。

To solve the problem, delete package-lock.json and node_modules .要解决此问题,请删除package-lock.jsonnode_modules Run npm install again.再次运行npm install Then run the schematics command.然后运行原理图命令。

Deleting package-lock.json usually solves this because the existing package-lock.json could be preventing NPM from properly sorting out dependencies and versions.删除package-lock.json通常可以解决这个问题,因为现有的package-lock.json可能会阻止 NPM 正确排序依赖项和版本。 So there are version updates deep down in the indirect dependencies that could be clashing and causing this error.因此,在间接依赖关系中存在版本更新,可能会发生冲突并导致此错误。

Just specify the same version for each package at installation:只需在安装时为每个 package 指定相同的版本:

 ng update @angular/core@12 @angular/cli@12 ng update @angular-eslint/schematics@12

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何为 protractor 项目设置 angular-eslint? - How do I need to setup angular-eslint for a protractor project? 如何添加@angular-eslint/schematics? 错误 - How add @angular-eslint/schematics? Error 如何运行@angular-eslint/schematics:convert-tslint-to-eslint - How to run @angular-eslint/schematics:convert-tslint-to-eslint 将 tslint 迁移到 @angular-eslint/schematics:ERESOLVE 无法解析依赖树:@angular/compiler@12.1.2 - Migrate tslint to @angular-eslint/schematics: ERESOLVE unable to resolve dependency tree: @angular/compiler@12.1.2 角编译器输出脚本,其中包含未定义的this - Angular-compiler outputs script that contain undefined this 在@angular-eslint/template 中使用缩进规则 - use of indent rule in @angular-eslint/template Angular 9 + eslint:找不到规则“@angular-eslint/…”的错误定义 - Angular 9 + eslint: error Definition for rule '@angular-eslint/…' was not found 使用“typescript-eslint/recommended”和“@angular-eslint/recommended”扩展多个规则集可以吗? - Extending multiple rule-sets using "typescript-eslint/recommended" with "@angular-eslint/recommended" is this okay to do? @angular-eslint/no-input-rename ESLint 规则有什么意义? - What is the point of the @angular-eslint/no-input-rename ESLint rule? 如何防止规则 `@angular-eslint/template/i18n` 掉落 `mat-icon` 元素 - How to prevent rule `@angular-eslint/template/i18n` from linting `mat-icon` elements
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM