【问题标题】:Uncaught TypeError: ctorParameters.map is not a function after updating to Angular 7未捕获的类型错误:更新到 Angular 7 后,ctorParameters.map 不是函数
【发布时间】:2018-11-01 12:33:22
【问题描述】:

我最近将我的 Angular 项目更新为 Angular 7。现在,当我从 CLI 运行“ng serve --open”时,我收到以下错误:

未捕获的类型错误:ctorParameters.map 不是函数 在 ReflectionCapabilities._ownParameters (core.js:1394) 在 ReflectionCapabilities.parameters (core.js:1426) 在 JitReflector.parameters (platform-b​​rowser-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 时,它可以工作。但为什么呢?

【问题讨论】:

  • 嘿!你解决了吗?
  • 很遗憾没有。即使在更新到 Angular 7.0.2 之后也没有。如前所述,使用--aot,它可以工作,但是在更改后重新编译时需要很长时间。
  • 我在 7.0.2 上,当不使用 es5 作为目标时会发生这种情况。呸
  • Es5 基本上可以正常工作。
  • 哈,你们是对的!带有目标 es5 的 7.0.2 有效。好的,非常感谢!

标签: javascript node.js angular typescript npm


【解决方案1】:

Angular 发布更新版本7.0.2
这个错误应该被修复,
运行ng update --all进行更新

【讨论】:

  • 我试过了,但还是出现同样的错误。我需要清理 npm 缓存吗?
猜你喜欢
  • 2017-06-03
  • 1970-01-01
  • 1970-01-01
  • 2022-07-30
  • 2022-11-19
  • 1970-01-01
  • 2019-06-06
  • 2019-05-24
  • 2021-12-15
相关资源
最近更新 更多