【发布时间】:2021-07-03 08:42:34
【问题描述】:
问题
我正在尝试从 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 has no exported member 'eeFactoryDef',这是我能找到的关于这个问题的唯一线索,但它并没有真正帮助我。
我尝试删除我的整个 node_modules 文件夹并使用 npm i 重新安装 npm 依赖项。我也试过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 本身。
Package.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"
}
}
我在这里遗漏或不理解什么?
【问题讨论】:
-
不知道是什么原因造成的,但是使用guide from Angular itself逐个版本升级,我再也没有收到错误了。不要像我一样傻。
标签: angular typescript npm package.json angular11