简体   繁体   English

Angular 6.0.1 CLI在“ng lint --type-check”执行时抛出“Architect”错误

[英]Angular 6.0.1 CLI throws “Architect” error on “ng lint --type-check” execution

After the Angular and Angular CLI update to v6, my lint configuration is throwing the following error everytime I try to run ng lint --type-check : 在Angular和Angular CLI更新到v6之后,每次我尝试运行ng lint --type-check ,我的lint配置都会抛出以下错误:

Architect commands with multiple targets cannot specify overrides. 具有多个目标的架构师命令无法指定替代。 'lint' would be run on the following projects: atlas-fe,atlas-fe-e2e 'lint'将在以下项目中运行:atlas-fe,atlas-fe-e2e

Error: Architect commands with multiple targets cannot specify overrides. 错误:具有多个目标的架构师命令无法指定替代。 'lint' would be run on the following projects: atlas-fe,atlas-fe-e2e 'lint'将在以下项目中运行:atlas-fe,atlas-fe-e2e
at LintCommand.validate (/home/nroma/workspace/atlas/proto-fe/node_modules/@angular/cli/models/architect-command.js:75:23) 在LintCommand.validate(/home/nroma/workspace/atlas/proto-fe/node_modules/@angular/cli/models/architect-command.js:75:23)
at /home/nroma/workspace/atlas/proto-fe/node_modules/@angular/cli/models/command-runner.js:274:39 在/home/nroma/workspace/atlas/proto-fe/node_modules/@angular/cli/models/command-runner.js:274:39
at Generator.next () 在Generator.next()
at /home/nroma/workspace/atlas/proto-fe/node_modules/@angular/cli/models/command-runner.js:7:71 在/home/nroma/workspace/atlas/proto-fe/node_modules/@angular/cli/models/command-runner.js:7:71
at new Promise () 在新的承诺()
at __awaiter (/home/nroma/workspace/atlas/proto-fe/node_modules/@angular/cli/models/command-runner.js:3:12) 在__awaiter(/home/nroma/workspace/atlas/proto-fe/node_modules/@angular/cli/models/command-runner.js:3:12)
at validateAndRunCommand (/home/nroma/workspace/atlas/proto-fe/node_modules/@angular/cli/models/command-runner.js:273:12) 在validateAndRunCommand(/home/nroma/workspace/atlas/proto-fe/node_modules/@angular/cli/models/command-runner.js:273:12)
at Object. 在对象。 (/home/nroma/workspace/atlas/proto-fe/node_modules/@angular/cli/models/command-runner.js:100:26) (/home/nroma/workspace/atlas/proto-fe/node_modules/@angular/cli/models/command-runner.js:100:26)
at Generator.next () 在Generator.next()
at fulfilled (/home/nroma/workspace/atlas/proto-fe/node_modules/@angular/cli/models/command-runner.js:4:58) 满足(/home/nroma/workspace/atlas/proto-fe/node_modules/@angular/cli/models/command-runner.js:4:58)

I'm using node v9.9.0 (npm v6.0.1) . 我正在使用node v9.9.0(npm v6.0.1)

This is my package.json : 这是我的package.json

{
  "name": "atlas-fe",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "npm run lint-ts && npm run lint-css",
    "lint-ts": "npm run format-ts && ng lint --type-check",
    "lint-css": "npm run format-css && stylelint \"src/**/*.{scss,css}\"",
    "format": "npm run format-ts && npm run format-css",
    "format-ts": "clang-format -i --glob=\"{src,e2e}/**/*.{js,ts}\"",
    "format-css": "stylefmt -c .stylelintrc -r \"src/**/*.{scss,css}\"",
    "e2e": "ng e2e",
    "precommit": "npm run lint"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.0.1",
    "@angular/cdk": "^6.0.1",
    "@angular/common": "^6.0.1",
    "@angular/compiler": "^6.0.1",
    "@angular/core": "^6.0.1",
    "@angular/flex-layout": "6.0.0-beta.15",
    "@angular/forms": "^6.0.1",
    "@angular/http": "^6.0.1",
    "@angular/material": "^6.0.1",
    "@angular/platform-browser": "^6.0.1",
    "@angular/platform-browser-dynamic": "^6.0.1",
    "@angular/router": "^6.0.1",
    "core-js": "^2.4.1",
    "fuse.js": "^3.2.0",
    "rxjs": "^6.1.0",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.6.1",
    "@angular/cli": "^6.0.1",
    "@angular/compiler-cli": "^6.0.1",
    "@angular/language-service": "^6.0.1",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "clang-format": "^1.2.2",
    "codelyzer": "^4.1.0",
    "husky": "^0.14.3",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "node-sass": "^4.5.3",
    "protractor": "~5.1.2",
    "stylefmt": "^6.0.0",
    "stylelint-config-recommended": "^1.0.0",
    "ts-node": "~3.2.0",
    "tslint": "~5.7.0",
    "typescript": "~2.7.2"
  }
}

It seems the CLI now defines two apps for your: your-site and your-site-e2e. CLI现在似乎为您定义了两个应用程序:your-site和your-site-e2e。 Running ng lint implicitly runs both by adding the two project names after the command somewhere under the hood. 运行ng lint通过在命令之后的某个位置添加两个项目名称来隐式运行。

However, if you add the --type-check flag to your command the implicit result becomes ng lint --type-check your-site your-site-e2e which is an invalid order of arguments. 但是,如果在命令中添加--type-check标志,则隐式结果将变为ng lint --type-check your-site your-site-e2e ,这是一个无效的参数顺序。

To fix it change the following line: 要修复它,请更改以下行:

"lint-ts": "npm run format-ts && ng lint --type-check",

to the explicit variant: 显式变体:

"lint-ts": "npm run format-ts && ng lint atlas-fe atlas-fe-e2e --type-check",

There is an open issue about this on the angular-cli github but so far not much activity. 在angular-cli github上有一个关于这个的公开问题,但到目前为止没有多少活动。

I finally found a solution to this problem. 我终于找到了解决这个问题的方法。 You need to specify the target for the lint command which is both the project & the project-e2e . 您需要为lint命令指定目标,该命令既是projectproject-e2e So in my case I had this object in my script: 所以在我的情况下,我的脚本中有这个对象:

"ng": "ng",
"start": "ng serve",
"build": "ng build --prod ",
"test": "ng test",
"lint": "ng lint --force ",

I just changed the lint line : 我只是改变了棉绒线:

    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod",
    "lint": "ng lint --force name-project name-project-e2e",

ng lint 在 Angular 14 中引发节点错误:UnhandledPromiseRejectionWarning:#<object><div id="text_translate"><p> 我将我的应用程序从 Angular 13 升级到 14,现在当我尝试使用安装了最新 eslint 的<strong>ng lint</strong>命令时,出现此错误:</p><pre> (node:15376) UnhandledPromiseRejectionWarning: #&lt;Object&gt; (Use `node --trace-warnings...` to show where the warning was created) (node:15376) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with.catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:15376) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.</pre><p> 我不知道如何解决这个问题,而无需降级回 13。这是我的 devDependencies:</p><pre> "devDependencies": { "@angular-devkit/build-angular": "^14.2.1", "@angular-eslint/builder": "14.0.3", "@angular-eslint/eslint-plugin": "14.0.3", "@angular-eslint/eslint-plugin-template": "14.0.3", "@angular-eslint/schematics": "14.0.3", "@angular-eslint/template-parser": "14.0.3", "@angular/cli": "^14.2.1", "@angular/compiler-cli": "^14.2.0", "@angular/language-service": "^14.2.0", "@ngxs/devtools-plugin": "~3.7.1", "@progress/kendo-licensing": "~1.2.2", "@types/lodash": "~4.14.168", "@typescript-eslint/eslint-plugin": "5.29.0", "@typescript-eslint/parser": "5.29.0", "@webcomponents/custom-elements": "^1.4.3", "eslint": "^8.18.0", "eslint-plugin-deprecation": "^1.3.2", "typescript": "^4.6.4" }</pre></div></object> - ng lint throws Node error in Angular 14: UnhandledPromiseRejectionWarning: #<Object>

暂无
暂无

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

相关问题 ng lint 在 Angular 14 中引发节点错误:UnhandledPromiseRejectionWarning:#<object><div id="text_translate"><p> 我将我的应用程序从 Angular 13 升级到 14,现在当我尝试使用安装了最新 eslint 的<strong>ng lint</strong>命令时,出现此错误:</p><pre> (node:15376) UnhandledPromiseRejectionWarning: #&lt;Object&gt; (Use `node --trace-warnings...` to show where the warning was created) (node:15376) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with.catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:15376) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.</pre><p> 我不知道如何解决这个问题,而无需降级回 13。这是我的 devDependencies:</p><pre> "devDependencies": { "@angular-devkit/build-angular": "^14.2.1", "@angular-eslint/builder": "14.0.3", "@angular-eslint/eslint-plugin": "14.0.3", "@angular-eslint/eslint-plugin-template": "14.0.3", "@angular-eslint/schematics": "14.0.3", "@angular-eslint/template-parser": "14.0.3", "@angular/cli": "^14.2.1", "@angular/compiler-cli": "^14.2.0", "@angular/language-service": "^14.2.0", "@ngxs/devtools-plugin": "~3.7.1", "@progress/kendo-licensing": "~1.2.2", "@types/lodash": "~4.14.168", "@typescript-eslint/eslint-plugin": "5.29.0", "@typescript-eslint/parser": "5.29.0", "@webcomponents/custom-elements": "^1.4.3", "eslint": "^8.18.0", "eslint-plugin-deprecation": "^1.3.2", "typescript": "^4.6.4" }</pre></div></object> - ng lint throws Node error in Angular 14: UnhandledPromiseRejectionWarning: #<Object> Angular CLI-ng e2e引发错误 - Angular CLI - ng e2e throws error 不同文件上的角度cli错误输出 - angular cli lint error export on a different file 角度4,使皮棉错误致命 - Angular 4, Make ng lint error fatal 无法在我的angular-cli项目上运行ng lint - Can't run ng lint on my angular-cli project Angular 2 CLI:ng测试错误 - Angular 2 CLI: ng test error Angular CLI ng新错误 - Angular CLI ng new error Angular 2 Cli:ng服务错误 - Angular 2 Cli: ng serve error Ng 测试抛出错误找不到模块 &#39;angular-cli/plugins/karma&#39; - Ng test throws an error Cannot find module 'angular-cli/plugins/karma' ng测试抛出错误:找不到模块&#39;@ angular-cli / plugins / karma&#39; - ng test throws Error: Cannot find module '@angular-cli/plugins/karma'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM