Angular 由于 IVY 导致 8 到 9 个升级问题

Angular 8 to 9 upgrade issues due to IVY

我最近将我的 Angular 8 应用程序升级到 Angular 9,一切都很顺利,但是在 运行 应用程序上我不断收到此错误。


    Uncaught TypeError: Cannot set property ɵfac of function ngf(element) {
            this.element = element;
            this.filters = [];
            this.lastFileCount =...... } which has only a getter
        at ngf.directive.js:335
        at Module../node_modules/angular-file/__ivy_ngcc__/file-upload/ngf.directive.js (ngf.directive.js:339)
        at __webpack_require__ (bootstrap:79)
        at Object../node_modules/angular-file/__ivy_ngcc__/file-upload/ngfSelect.directive.js (ngfSelect.directive.js:26)
        at __webpack_require__ (bootstrap:79)
        at Object../node_modules/angular-file/__ivy_ngcc__/index.js (index.js:6)
        at __webpack_require__ (bootstrap:79)
        at Module../src/app/app.module.ts (app.component.ts:13)
        at __webpack_require__ (bootstrap:79)
        at Module../src/main.ts (main.ts:1)
    

我的 tsconfig.app.json 文件看起来像这样


    {
      "extends": "./tsconfig.json",
      "compilerOptions": {
        "outDir": "../out-tsc/app",
        "types": ["node"],
        "moduleResolution": "node"
      },
      "files": [
        "src/main.ts",
        "src/polyfills.ts"
      ],
      "angularCompilerOptions": {
        "enableIvy": true
      },
      "exclude": ["src/**/*.spec.ts", "src/test/**/*", "e2e/**/*"]
    }

tsconfig.json:


    {
      "compileOnSave": false,
      "compilerOptions": {
        "baseUrl": "./",
        "outDir": "./dist/out-tsc",
        "sourceMap": true,
        "declaration": false,
        "module": "esnext",
        "moduleResolution": "node",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "importHelpers": true,
        "target": "es2015",
        "types": ["jest"],
        "typeRoots": ["node_modules/@types"],
        "lib": ["es2018", "dom"]
      }
    }

ng --version

的输出

    Angular CLI: 9.1.12
    Node: 12.3.1
    OS: darwin x64
    
    Angular: 9.1.12
    ... animations, cli, common, compiler, compiler-cli, core, forms
    ... language-service, platform-browser, platform-browser-dynamic
    ... router
    Ivy Workspace: Yes
    
    Package                            Version
    ------------------------------------------------------------
    @angular-devkit/architect          0.901.12
    @angular-devkit/build-angular      0.901.12
    @angular-devkit/build-optimizer    0.901.12
    @angular-devkit/build-webpack      0.901.12
    @angular-devkit/core               9.1.12
    @angular-devkit/schematics         9.1.12
    @angular/cdk                       9.2.4
    @angular/material                  9.2.4
    @angular/material-moment-adapter   9.2.4
    @ngtools/webpack                   9.1.12
    @schematics/angular                9.1.12
    @schematics/update                 0.901.12
    rxjs                               6.6.3
    typescript                         3.8.3
    webpack                            4.42.0

我不确定我是否遗漏了任何特定于 Angular 9.

的配置

看来问题出在 angular-file node_module

根据回购所有者的评论,解决方案可以升级到 2.0 版。 他提到该软件包在版本 2

上支持 Ivy

https://github.com/AckerApple/angular-file/issues/65#issuecomment-549402306