Ionic 此版本的CLI仅与Angular版本^13.0.0兼容,但找到的是Angular版本12.2.13

u0njafvf  于 2022-12-20  发布在  Ionic
关注(0)|答案(3)|浏览(264)

我的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": []
  }
2g32fytz

2g32fytz1#

npm i @angular-devkit/build-angular@12.2.13 --force
npm i @angular/cli@12
w8ntj3qf

w8ntj3qf2#

我也有同样的错误,但我使用的是V11.2.14。
简单的解决方案是转到 package.json 文件并更改

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

(it位于依赖项内)
到您的兼容版本。
所以当我把它改成

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

成功了。

xnifntxz

xnifntxz3#

如果要在多个主要版本之间更新Angular 版本-如果在使用"ng update"时出现以下错误-"不支持同时更新'@angular/cli '的多个主要版本。请单独迁移每个主要版本。在工作区目录中运行' ng update@angular/cli@12 '以更新到'@angular/cli'的最新' 12.x '版本。"
您必须执行以下步骤才能逐步更新:
1.运行ng update
1.您将获得要使用update命令更新的项目列表
1.与--allow-dirty --force一起运行每个命令以进行更新
例如:

要更新Angular cdk,请运行ng update @angular/cdk@12 --allow-dirty --force
1.对列表中的所有项目执行上述操作
1.在使用给定的命令完成项目更新后,再次运行ng build并检查是否所有错误都消失了。
1.如果您有更多关于更新的错误,请再次运行ng update并继续执行步骤2到5,直到所有更新错误得到解决

相关问题