“这可能意味着声明 TranslateModule 的库 (@ngx-translate/core) 与 Angular Ivy 不兼容”Angular 应用程序中的错误

问题描述 投票:0回答:1

按照 update.angular.io

中的步骤从 Angular 15 升级到 16 后,当我在 Angular 应用程序中运行 npm start 时,出现以下错误

这可能意味着声明 TranslateModule 的库 (@ngx-translate/core) 与 Angular Ivy 不兼容。检查该库是否有新版本可用,如果有则更新。还可以考虑与库的作者核实,看看该库是否与 Ivy 兼容。

除此之外,我还得到了错误

此导入包含错误,可能会影响依赖此 NgModule 的组件 我的应用程序的大约 2 个模块以及 “LoggerModule”似乎不是 NgModule 类。

要说的重要一点是,这个应用程序与 Angular 15 完美配合,但在迁移到 Angular 16 的过程中出现了问题。

这是我的package.json:

{
  "name": "client-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": "^16.2.12",
    "@angular/cdk": "^15.2.9",
    "@angular/common": "^16.2.12",
    "@angular/compiler": "^16.2.12",
    "@angular/core": "^16.2.12",
    "@angular/forms": "^16.2.12",
    "@angular/material": "^15.2.9",
    "@angular/material-moment-adapter": "^15.2.9",
    "@angular/platform-browser": "^16.2.12",
    "@angular/platform-browser-dynamic": "^16.2.12",
    "@angular/router": "^16.2.12",
    "@ngx-translate/core": "^13.0.0",
    "@ngx-translate/http-loader": "^6.0.0",
    "@types/file-saver": "^2.0.1",
    "ajv": "^6.12.6",
    "babel-polyfill": "^6.26.0",
    "classlist.js": "^1.1.20150312",
    "core-js": "^3.8.1",
    "file-saver": "^2.0.5",
    "jwt-decode": "^3.1.2",
    "material-design-icons": "^3.0.1",
    "moment": "^2.29.1",
    "ngx-logger": "^4.1.9",
    "rxjs": "~6.6.0",
    "rxjs-compat": "^6.6.3",
    "tslib": "^2.0.0",
    "web-animations-js": "^2.3.2",
    "zone.js": "~0.13.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^16.2.12",
    "@angular-devkit/schematics": "^16.2.12",
    "@angular/cli": "^16.2.12",
    "@angular/compiler-cli": "^16.2.12",
    "@angular/language-service": "^16.2.12",
    "@types/chai": "^4.2.14",
    "@types/cucumber": "^6.0.1",
    "@types/jasmine": "~3.6.0",
    "@types/jasminewd2": "^2.0.8",
    "@types/node": "^12.11.1",
    "codelyzer": "^6.0.0",
    "cucumber": "^6.0.7",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~6.4.2",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-coverage-istanbul-reporter": "^3.0.3",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "1.5.0",
    "mail-listener2": "^0.3.1",
    "oidc-client": "^1.10.1",
    "protractor": "~7.0.0",
    "protractor-cucumber-framework": "^6.2.1",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~4.9.5"
  }
}

我尝试过但没有成功:

  • 删除
    node_modules
    ,清除
    npm cache
    ,然后执行
    npm install
  • npm i @ngx-translate/core
  • ctrl + c,服务
  • "postinstall": "ngcc"
    添加到我的 package.json
angular upgrade ngx-translate angular15 angular16
1个回答
0
投票

正如错误所述,将 @ngx-translate/core 更新到新版本就是诀窍。我刚刚执行了

npm i @ngx-translate/[email protected]
并且成功了。谢谢@安德烈

© www.soinside.com 2019 - 2024. All rights reserved.