【问题标题】:This version of CLI is only compatible with Angular versions此版本的 CLI 仅与 Angular 版本兼容
【发布时间】:2021-06-28 13:33:41
【问题描述】:

我在全球安装了 Angular CLI: 9.1.12。如果我尝试从我的根应用程序运行 ng serve,它会引发以下错误:

This version of CLI is only compatible with Angular versions ^8.0.0-beta || >=8.0.0 <9.0.0,
but Angular version 9.1.13 was found instead.

我尝试更改全局 CLI 版本但没有成功。

package.json

{
  "name": "my-app",
  "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": "^9.0.0-next.2",
    "@angular/cdk": "^8.1.3",
    "@angular/common": "^9.0.0-next.2",
    "@angular/compiler": "^9.0.0-next.2",
    "@angular/core": "^9.0.0-next.2",
    "@angular/forms": "^9.0.0-next.2",
    "@angular/material": "^8.1.3",
    "@angular/platform-browser": "^9.0.0-next.2",
    "@angular/platform-browser-dynamic": "^9.0.0-next.2",
    "@angular/router": "^9.0.0-next.2",
    "@ng-select/ng-select": "^2.14.0",
    "bootstrap": "^4.1.3",
    "chart.js": "^2.7.3",
    "common-library": "file:../CommonLibrary/dist/common-library",
    "core-js": "^2.5.4",
    "font-awesome": "^4.7.0",
    "jquery": "^3.3.1",
    "ng4-loading-spinner": "^1.2.3",
    "ng6-toastr-notifications": "^1.0.4",
    "ngx-bootstrap": "^5.1.1",
    "node-sass": "^4.10.0",
    "popper.js": "^1.14.5",
    "rxjs": "~6.5.2",
    "rxjs-compat": "^6.5.2",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.802.2",
    "@angular-devkit/build-ng-packagr": "~0.802.2",
    "@angular/cli": "^8.2.2",
    "@angular/compiler-cli": "^9.0.0-next.2",
    "@angular/language-service": "^9.0.0-next.2",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "^5.0.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "ng-packagr": "^5.3.0",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tsickle": "^0.36.0",
    "tslib": "^1.9.0",
    "tslint": "~5.11.0",
    "typescript": "~3.5.3"
  }
}

我能做什么?

【问题讨论】:

    标签: angular npm command-line-interface angular-cli


    【解决方案1】:

    肯定是因为angular版本和angular cli版本。

    首先输入ng v 以检查所有版本并使其与主要版本匹配。

    此外,如果您想从项目特定的 cli 运行 cli,则只需键入

    npm run start,而不是ng serve

    【讨论】:

    • 我的应用程序中的 ng v 显示 Angular/CLI 8.3.29。我尝试匹配全局版本,但运行 ng serve 时出现相同的错误
    • 将您的 cli 版本更新为 9.x.x 并运行 npm start 而不是 ng serve
    • 你说的是本地版本吗?你知道命令吗?
    • 是的。只需执行npm install @angular/cli@9.1.13 并重试。
    • 不幸的是,更改 CLI 版本会产生大量 node_module 错误An accessor cannot be declared in an ambient context.
    猜你喜欢
    • 2022-11-21
    • 2022-11-02
    • 1970-01-01
    • 1970-01-01
    • 2021-12-25
    • 1970-01-01
    • 2019-02-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多