Ошибка после обновления с угла 5,2 до 7,2 - PullRequest
1 голос
/ 22 апреля 2019

Недавно мы обновили с угловой 5,2 до угловой 7,2, выполнив шаги с https://update.angular.io/

После этого, когда мы запускаем npm из терминала и пытаемся использовать пользовательский интерфейс, мы получаем ошибку ниже в браузереconsole,

compiler.js:2430 Uncaught Error: Can't resolve all parameters for ApplicationModule: (?).
    at syntaxError (compiler.js:2430)
    at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getDependenciesMetadata (compiler.js:18984)
    at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getTypeMetadata (compiler.js:18877)
    at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (compiler.js:18745)
    at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleSummary (compiler.js:18555)
    at compiler.js:18669
    at Array.forEach (<anonymous>)
    at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (compiler.js:18657)
    at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleSummary (compiler.js:18555)
    at compiler.js:18642

Ниже приведены некоторые из имеющихся у нас артефактов:

package.json

{
  "name": "angular-poc",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod",
    "buildLocal": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "7.2.13",
    "@angular/cdk": "7.3.7",
    "@angular/common": "7.2.13",
    "@angular/compiler": "7.2.13",
    "@angular/core": "7.2.13",
    "@angular/forms": "7.2.13",
    "@angular/http": "7.2.13",
    "@angular/material": "7.3.7",
    "@angular/platform-browser": "7.2.13",
    "@angular/platform-browser-dynamic": "7.2.13",
    "@angular/router": "7.2.13",
    "@ngx-progressbar/core": "5.3.2",
    "@ngx-progressbar/http": "5.3.2",
    "@nicky-lenaers/ngx-scroll-to": "2.0.0",
    "@types/lodash": "4.14.123",
    "ag-grid": "~17.1.1",
    "ag-grid-angular": "~17.1.0",
    "ag-grid-enterprise": "~17.1.1",
    "angular-tabs-component": "1.0.6",
    "classlist.js": "1.1.20150312",
    "core-js": "^3.0.1",
    "font-awesome": "4.7.0",
    "keycloak-angular": "6.1.0",
    "ng-animate": "0.3.4",
    "ng-pick-datetime": "7.0.0",
    "ng2-scroll-to-el": "1.2.1",
    "ngx-toastr": "10.0.2",
    "reflect-metadata": "0.1.12",
    "rxjs": "6.4.0",
    "tslib": "1.9.3",
    "web-animations-js": "2.3.1",
    "zone.js": "0.9.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "0.13.8",
    "@angular/cli": "^7.3.8",
    "@angular/compiler-cli": "7.2.13",
    "@angular/language-service": "7.2.13",
    "@types/jasmine": "3.3.12",
    "@types/jasminewd2": "2.0.6",
    "@types/node": "11.13.5",
    "codelyzer": "5.0.0",
    "jasmine-core": "3.4.0",
    "jasmine-spec-reporter": "4.2.1",
    "karma": "4.1.0",
    "karma-chrome-launcher": "2.2.0",
    "karma-coverage-istanbul-reporter": "2.0.5",
    "karma-jasmine": "2.0.1",
    "karma-jasmine-html-reporter": "1.4.0",
    "protractor": "5.4.2",
    "ts-node": "8.1.0",
    "tslint": "~5.9.1",
    "typescript": "3.2.4"
  }
}

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "paths": {
      "core-js/es6/*": [
        "node_modules/core-js/es/*"
      ],
      "core-js/es7/*": [
        "node_modules/core-js/es/*"
      ]
    },
    "importHelpers": true,
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ],
    "module": "es2015",
    "baseUrl": "./"
  }
}

tsconfig.app.json

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "paths": {
      "core-js/es6/*": [
        "../node_modules/core-js/es/*"
      ],
      "core-js/es7/*": [
        "../node_modules/core-js/es/*"
      ]
    },
    "outDir": "../out-tsc/app",
    "baseUrl": "./",
    "module": "es2015",
    "types": []
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}

polyfills.ts

/**
 * This file includes polyfills needed by Angular and is loaded before the app.
 * You can add your own extra polyfills to this file.
 *
 * This file is divided into 2 sections:
 *   1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
 *   2. Application imports. Files imported after ZoneJS that should be loaded before your main
 *      file.
 *
 * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
 * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
 * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
 *
 * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
 */

/***************************************************************************************************
 * BROWSER POLYFILLS
 */

/** IE9, IE10 and IE11 requires all of the following polyfills. **/
import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es7/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es7/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/weak-map';
import 'core-js/es6/set';

/** IE10 and IE11 requires the following for NgClass support on SVG elements */
import 'classlist.js';  // Run `npm install --save classlist.js`.

/** IE10 and IE11 requires the following for the Reflect API. */
//import 'core-js/es6/reflect';
import 'core-js/es7/reflect';

/**
 * Required to support Web Animations `@angular/platform-browser/animations`.
 * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
 **/
import 'web-animations-js';  // Run `npm install --save web-animations-js`.



/***************************************************************************************************
 * Zone JS is required by default for Angular itself.
 */
import 'zone.js/dist/zone';  // Included with Angular CLI.



/***************************************************************************************************
 * APPLICATION IMPORTS
 */

1 Ответ

0 голосов
/ 22 июля 2019

После обновления core-js с 2.6.9 до 3.1.4 я получил ту же ошибку, что и мне ... Следующий ответ на угловой вопрос 26128 дал мне подсказку.

Я добавил следующую строку в polyfill.ts, что решило проблему:

import 'core-js/proposals/reflect-metadata';

В качестве альтернативы, вы можете использовать reflect-metadata:

npm install reflect-metadata и добавить import 'reflect-metadata/Reflect'; к polyfill.ts.

...