为什么在尝试升级Angular时会出现“无导出成员”错误?

问题

我正在尝试从 Angular V9 升级到 V11,但由于以下错误而苦苦挣扎

Namespace node_module/@angular/core/core has no exported member ??FactoryDeclaration
Namespace node_module/@angular/core/core has no exported member ??InjectorDeclaration
Namespace node_module/@angular/core/core has no exported member ??NgModuleDeclaration
Namespace node_module/@angular/core/core has no exported member ???ComponentDeclaration

但我不完全确定这意味着什么以及如何解决它。

我试过的

我看过一个类似的问题:Ng serve throwing @angular/core/core 没有导出成员 'eeFactoryDe​​f'这是我能找到的唯一线索,但它并没有真正帮助我。

我尝试删除我的整个 node_modules 文件夹并使用npm i. 我也试过npm ci了。我也尝试添加

      "@angular/core/*": [
        "./node_modules/@angular/core/*"
      ]

或者

      "@angular/*": [
        "./node_modules/@angular/*"
      ]

到我的tsconfig.json,但这也没有帮助。

我认为是什么问题

我对此一无所知,但我认为我的 NPM 依赖项的路径有问题,因为它引用了@angular/core/core,但我的node_modules.

如果我转到node_modules/@angular/core/core.d.ts我认为是/core/core路径的文件,尽管我不确定这一点,然后我也会在那里看到相同的错误,这让我更加困惑,因为我认为问题出在 Angular 和依赖项之间但不在 Angular 内部。

包.json

{
  "name": "WorthaShot",
  "version": "0.0.3",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "build:prod": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~12.0.0-next.7",
    "@angular/cdk": "^11.2.7",
    "@angular/common": "~12.0.0-next.7",
    "@angular/compiler": "~12.0.0-next.7",
    "@angular/core": "~11.2.8",
    "@angular/fire": "^6.1.4",
    "@angular/flex-layout": "^10.0.0-beta.32",
    "@angular/forms": "~12.0.0-next.7",
    "@angular/material": "^11.2.7",
    "@angular/platform-browser": "~12.0.0-next.7",
    "@angular/platform-browser-dynamic": "~12.0.0-next.7",
    "@angular/router": "~12.0.0-next.7",
    "@angular/service-worker": "~12.0.0-next.7",
    "@fortawesome/angular-fontawesome": "^0.8.2",
    "@fortawesome/fontawesome-common-types": "^0.2.35",
    "@fortawesome/fontawesome-svg-core": "^1.2.35",
    "@fortawesome/free-brands-svg-icons": "^5.15.3",
    "@fortawesome/free-solid-svg-icons": "^5.15.3",
    "@ngbmodule/material-carousel": "^0.7.1",
    "@ngx-meta/core": "^9.0.0",
    "@ngx-translate/core": "^13.0.0",
    "@ngx-translate/http-loader": "^6.0.0",
    "firebase": "^8.3.2",
    "flag-icon-css": "^3.5.0",
    "guid-typescript": "^1.0.9",
    "ngx-color-picker": "^10.1.0",
    "ngx-image-compress": "^8.0.4",
    "ngx-markdown": "^10.1.1",
    "ngx-sharebuttons": "^8.0.5",
    "ngx-spinner": "^10.0.1",
    "ngx-toastr": "^13.2.1",
    "rxjs": "~6.6.7",
    "tslib": "^2.2.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.1102.7",
    "@angular/cli": "~11.2.7",
    "@angular/compiler-cli": "~12.0.0-next.7",
    "@angular/language-service": "~12.0.0-next.7",
    "@types/jasmine": "~3.6.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^14.14.37",
    "codelyzer": "^6.0.1",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~6.3.2",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.10.2",
    "tslint": "~6.1.3",
    "typescript": "^4.2.3"
  }
}

我在这里缺少什么或不理解什么?

回答

如果您在安装了primeng 后遇到了这个问题,请注意最新版本的primeng (12.0.0-rc.1) 不适用于最新版本的angular。您需要安装更早版本的primeng,对我来说11.4 完美运行!

npm i primeng@11.4.2


以上是为什么在尝试升级Angular时会出现“无导出成员”错误?的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>