此版本的 CLI 仅与 Angular 版本 ^13.0.0 兼容,但发现 Angular 版本 12.2.13 [关闭]

Posted

技术标签:

【中文标题】此版本的 CLI 仅与 Angular 版本 ^13.0.0 兼容,但发现 Angular 版本 12.2.13 [关闭]【英文标题】:This version of CLI is only compatible with Angular versions ^13.0.0, but Angular version 12.2.13 was found instead [closed] 【发布时间】:2021-12-25 00:41:54 【问题描述】:

我的Ionic 项目在一个月前运行良好。今天当我尝试ionic serveionic build 时,出现以下错误:

哪个 CLI 版本与 Angular 12.2.13 版本兼容?如果你真的想知道我为什么要问这个问题,你可以进一步准备。

所以我按照 Angular 官方网站上的建议升级到 Angular 13,我使用了以下命令:npm @angular/cli@13 update @angular/core@13 @angular/cli@13

这条路线要求我将我的 Node.js 升级到版本 16(最新的,当前的)。将 Node.js 升级到 v16 后,我尝试升级到 Angular 13,在此过程中,由于不支持的依赖项等原因导致安装失败/停止。

我在谷歌上搜索了大多数解决方案,尝试过,并以一个找不到我所有插件的项目结束,等等。所以我通过将 Node.js v16 卸载到 v12 来逆转上述过程,删除了 npm、node_modules 文件夹,现在我又回到了我在图片中遇到以下错误的地方。

这是我来自ionic info的开发者环境:

这是我的 package.json 文件的副本:

    "dependencies": 
    "@angular/common": "~12.2.8",
    "@angular/core": "~12.2.8",
    "@angular/forms": "~12.2.8",
    "@angular/platform-browser": "~12.2.8",
    "@angular/platform-browser-dynamic": "~12.2.8",
    "@angular/router": "~12.2.8",
    "@babel/compat-data": "^7.8.0",
    "@ionic-native/app-version": "^5.36.0",
    "@ionic-native/call-number": "^5.36.0",
    "@ionic-native/camera": "^5.23.0",
    "@ionic-native/core": "^5.0.0",
    "@ionic-native/device": "^5.36.0",
    "@ionic-native/file": "^5.36.0",
    "@ionic-native/file-transfer": "^5.23.0",
    "@ionic-native/full-screen-image": "^5.23.0",
    "@ionic-native/in-app-browser": "^5.36.0",
    "@ionic-native/ionic-webview": "^5.36.0",
    "@ionic-native/keyboard": "^5.36.0",
    "@ionic-native/onesignal": "^5.36.0",
    "@ionic-native/photo-viewer": "^5.23.0",
    "@ionic-native/splash-screen": "^5.36.0",
    "@ionic-native/status-bar": "^5.36.0",
    "@ionic/angular": "^5.0.0",
    "@ionic/storage-angular": "^3.0.6",
    "bufferutil": "^4.0.1",
    "call-number": "^1.0.1",
    "cordova-plugin-actionsheet": "^2.3.3",
    "cordova-plugin-dialogs": "^2.0.2",
    "core-js": "^2.5.4",
    "rxjs": "~6.5.1",
    "tslib": "^1.9.0",
    "utf-8-validate": "^5.0.2",
    "zone.js": "~0.11.4"
  ,
  "devDependencies": 
    "@angular-devkit/build-angular": "^13.0.2",
    "@angular/cli": "^12.2.8",
    "@angular/compiler": "^12.2.8",
    "@angular/compiler-cli": "^12.2.8",
    "@angular/language-service": "~12.2.8",
    "@ionic/angular-toolkit": "^5.0.3",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "^5.0.0",
    "cordova-android": "^9.1.0",
    "cordova-plugin-app-version": "^0.1.12",
    "cordova-plugin-camera": "^6.0.0",
    "cordova-plugin-device": "^2.0.3",
    "cordova-plugin-file": "^6.0.2",
    "cordova-plugin-file-transfer": "git+https://github.com/apache/cordova-plugin-file-transfer.git",
    "cordova-plugin-inappbrowser": "^4.1.0",
    "cordova-plugin-ionic-keyboard": "^2.2.0",
    "cordova-plugin-ionic-webview": "^5.0.0",
    "cordova-plugin-splashscreen": "^6.0.0",
    "cordova-plugin-statusbar": "^2.4.3",
    "cordova-sqlite-storage": "^6.0.0",
    "jasmine-core": "^3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^6.3.4",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "onesignal-cordova-plugin": "^3.0.0",
    "protractor": "^7.0.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~4.3.5"
  ,
  "description": "Vuyou's Funerals",
  "cordova": 
    "plugins": 
      "cordova-plugin-inappbrowser": ,
      "mx.ferreyra.callnumber": ,
      "cordova-plugin-file-transfer": ,
      "onesignal-cordova-plugin": ,
      "cordova-plugin-camera": 
        "ANDROIDX_CORE_VERSION": "1.6.+"
      ,
      "cordova-plugin-ionic-webview": ,
      "cordova-plugin-ionic-keyboard": ,
      "cordova-plugin-splashscreen": ,
      "cordova-plugin-device": ,
      "cordova-plugin-statusbar": ,
      "cordova-sqlite-storage": ,
      "cordova-plugin-app-version": 
    ,
    "platforms": []
  

【问题讨论】:

使用 ngUpdate 在本地更新了 Angular @GaurangDhorda 我不明白你的意思?我要问的是,Angular v12.2.13 的正确 CLI 版本是什么? 尝试将angular-devkit/build-angular 版本从^13.0.2 更改为^12.2.8 这个问题是discussed on Meta,这解释了它的突然审查。 Please do not upload images of code/errors when asking a question. 【参考方案1】:

我遇到了同样的错误,但我使用的是 V 11.2.14。

简单的解决办法是去package.json文件改一下

"@angular-devkit/build-angular": "^13.0.2"

(在依赖项中)

到您的兼容版本。

所以当我把它改成

"@angular-devkit/build-angular": "~0.1102.3",

成功了。

【讨论】:

【参考方案2】:
npm i @angular-devkit/build-angular@12.2.13 --force
npm i @angular/cli@12

【讨论】:

以上是关于此版本的 CLI 仅与 Angular 版本 ^13.0.0 兼容,但发现 Angular 版本 12.2.13 [关闭]的主要内容,如果未能解决你的问题,请参考以下文章

安装特定版本的 ng cli

错误:npm install -g @angular/cli

无法将角度更新到版本 6

如何使用 CLI 创建特定版本的 Angular 项目?

如何获得 Angular 版本?

如何将 Angular CLI 升级到最新版本