我最近将Angular项目更新为Angular7。现在,当我从CLI运行“ ng serve --open”时,出现以下错误:
未捕获的TypeError:ctorParameters.map不是函数 在ReflectionCapabilities._ownParameters(core.js:1394) 在ReflectionCapabilities.parameters(core.js:1426) 在JitReflector.parameters(platform-browser-dynamic.js:48) 在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"
}
}
tsconfig:
{
"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"
}
}
angular.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
时可以运行。但是为什么呢?
答案 0 :(得分:1)
Angular发布了更新版本7.0.2
该错误应得到修复,
运行ng update --all
进行更新