javascript - 未捕获的类型错误:更新到 Angular 7 后,ctorParameters.map 不是函数
问题描述
我最近将我的 Angular 项目更新为 Angular 7。现在,当我从 CLI 运行“ng serve --open”时,我收到以下错误:
Uncaught TypeError: ctorParameters.map is not a function at ReflectionCapabilities._ownParameters (core.js:1394) at ReflectionCapabilities.parameters (core.js:1426) at JitReflector.parameters (platform-browser-dynamic.js:48) at CompileMetadataResolver. _getDependenciesMetadata (compiler.js:10202) 在 CompileMetadataResolver._getTypeMetadata (compiler.js:10155) 在 CompileMetadataResolver.getNonNormalizedDirectiveMetadata (compiler.js:9784) 在 CompileMetadataResolver.loadDirectiveMetadata (compiler.js:9647) 在 _filterJitIdentifiers.forEach (compiler.js: 23148) 在 Array.forEach () 在 _filterJitIdentifiers.forEach (compiler.js:23147)
我的 package.json 看起来像这样:
{
"name": "frontend",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^7.0.1",
"@angular/cdk": "^7.0.2",
"@angular/common": "^7.0.1",
"@angular/compiler": "^7.0.1",
"@angular/core": "^7.0.1",
"@angular/flex-layout": "^7.0.0-beta.19",
"@angular/forms": "^7.0.1",
"@angular/http": "^7.0.1",
"@angular/material": "^7.0.2",
"@angular/platform-browser": "^7.0.1",
"@angular/platform-browser-dynamic": "^7.0.1",
"@angular/router": "^7.0.1",
"@auth0/angular-jwt": "^2.0.0",
"@ngx-translate/core": "^11.0.0",
"@ngx-translate/http-loader": "^4.0.0",
"angular2-draggable": "^2.1.6",
"core-js": "^2.5.7",
"enhanced-resolve": "^4.1.0",
"moment": "^2.22.2",
"ng-drag-drop": "^5.0.0",
"ngx-quill": "^4.0.0",
"ngx-quill-editor": "^2.2.2",
"rxjs": "^6.3.3",
"rxjs-compat": "^6.0.0-rc.0",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.10.0",
"@angular/cli": "^7.0.3",
"@angular/compiler-cli": "^7.0.1",
"@angular/language-service": "^7.0.1",
"@types/jasmine": "~2.8.9",
"@types/jasminewd2": "~2.0.5",
"@types/node": "~10.12.1",
"codelyzer": "^4.5.0",
"jasmine-core": "~3.3.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.1.1",
"karma-chrome-launcher": "~2.2.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^2.0.4",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^1.4.0",
"node-sass": "^4.9.4",
"protractor": "~5.4.1",
"ts-node": "~7.0.1",
"tslint": "~5.11.0",
"typescript": "~3.1.3"
}
}
配置:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./src",
"paths": {
"@app/*": [
"./app/*"
]
},
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2018",
"typeRoots": [
"./node_modules/@types"
],
"lib": [
"es2018",
"dom"
],
"module": "es2015"
}
}
角.json:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"frontend": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"assets": [
"src/assets",
"src/favicon.ico"
],
"styles": [
"src/styles.scss",
"node_modules/quill/dist/quill.core.css",
"node_modules/quill/dist/quill.bubble.css",
"node_modules/ng-drag-drop/style.css"
],
"scripts": []
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "frontend:build"
},
"configurations": {
"production": {
"browserTarget": "frontend:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "frontend:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"karmaConfig": "./karma.conf.js",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"scripts": [],
"styles": [
"src/styles.scss",
"node_modules/quill/dist/quill.core.css",
"node_modules/quill/dist/quill.bubble.css",
"node_modules/ng2-drag-drop/style.css"
],
"assets": [
"src/assets",
"src/favicon.ico"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"frontend-e2e": {
"root": "e2e",
"sourceRoot": "e2e",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "./protractor.conf.js",
"devServerTarget": "frontend:serve"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"e2e/tsconfig.e2e.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "frontend",
"schematics": {
"@schematics/angular:component": {
"prefix": "app",
"styleext": "scss"
},
"@schematics/angular:directive": {
"prefix": "app"
}
}
}
我假设存在一些依赖错误(当前,当我运行“npm audit fix”时,NPM 向我显示 auth0/angular-jwt 库需要 Angular 6,已经存在 GitHub 问题,但即使我临时删除该库,错误仍然存在)。
编辑:当我运行ng serve --open --aot
它时。但为什么?
解决方案
Angular 发布了一个更新的版本7.0.2
,这个 bug 应该已经修复了,
运行ng update --all
更新
推荐阅读
- c++ - 如何在 UML 中显示地图?C++
- javascript - 多次执行axios请求只得到一个输出
- dataframe - 在 Julia 中转换 DataFrame 的多列的正确方法是什么?
- r - Plotly/Vistime - 重叠标签
- python-3.x - 混淆矩阵 - 当真/预测列都有值时的 TP
- api - 如果我的 API 受 OAuth 保护,我是否需要 Web 应用程序防火墙?
- python - 关于DataCamp关于p值的假设检验问题的问题
- single-sign-on - Keycloak 跨远程站点的高可用性
- javascript - 如何根据循环的索引动态设置key
- javascript - 将按钮添加到此表的最后一列的最简单方法是什么?