簡體   English   中英

AOT清理加載程序中的錯誤,無法以AOT模式構建Angular App

[英]Error in AOT cleanup loader, failed to build Angular App with AOT mode

在聽到了很多有關Angular AOT模式的信息之后,我想嘗試一下。 因此,我們將應用程序遷移到了Angular v4.1.2,並進行了所有必要的更改。 當我嘗試在Webpack配置文件中使用ngc-webpack插件配置的以下部分以AOT模式運行構建時,我陷入了一些未知錯誤。

new ngcWebpack.NgcWebpackPlugin({
        disabled: !AOT,
        tsConfig: helpers.root('tsconfig.webpack.json')
      }),

我的tsconfig.webpack.json文件如下:-

{
  "compilerOptions": {
    "target": "es5",
    "module": "es2015",
    "moduleResolution": "node",
    some ts configs
    ....
    ....
     ...
    "lib": [
      "dom",
      "es2015"
    ],
    "baseUrl": ".",
    "paths": {
      "@angular/*": ["node_modules/@angular/*"]
    },

    "typeRoots": [
      "node_modules/@types"
    ],
    "types": [
      "hammerjs",
      "node",
      "jasmine",
      "lodash",
      "source-map",
      "uglify-js",
      "webpack"
    ]
  },
  "exclude": [
    "node_modules",
    "dist",
    "src/**/*.spec.ts",
    "src/**/*.e2e.ts"
  ],
  "awesomeTypescriptLoaderOptions": {
    "forkChecker": true,
    "useWebpackText": true
  },
  "angularCompilerOptions": {
    "genDir": "./compiled",
    "skipMetadataEmit": true
  },
  "compileOnSave": false,
  "buildOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}

當我運行構建時,在完成94%的工作后,並使用令人敬畏的打字機加載器成功編譯后,aot-clean-compiles起作用並拋出如下所示的大堆棧跟蹤信息:-

ERROR in ./src/app/applications/xxx.component.ts
Module build failed: TypeError: refactor.program.getTypeChecker(...).getTypeFromTypeNode is not a function
    at _ctorParameterFromTypeReference (/Users/xxx/sources/migration/yyy/node_modules/src/aot-clean-transformer/loader/text-based-loader/loader.ts:57:58)
    at /Users/xxx/sources/migration/bm_dashbaord/node_modules/src/aot-clean-transformer/loader/text-based-loader/loader.ts:123:12
    at Array.map (native)
    at _addCtorParameters (/Users/xxx/sources/migration/bm_dashbaord/node_modules/src/aot-clean-transformer/loader/text-based-loader/loader.ts:122:46)
    at /Users/xxx/sources/migration/bm_dashbaord/node_modules/src/aot-clean-transformer/loader/text-based-loader/loader.ts:154:11
    at Array.forEach (native)
    at _removeDecorators (/Users/xxx/sources/migration/bm_dashbaord/node_modules/src/aot-clean-transformer/loader/text-based-loader/loader.ts:147:6)
    at Object.aotCleanLoader (/Users/xxx/sources/migration/bm_dashbaord/node_modules/src/aot-clean-transformer/loader/text-based-loader/loader.ts:303:7)

我在這個錯誤上停留了相當長的時間,無法弄清楚我在做什么錯。 請有人在這里幫我。

您可以檢查版本是否為2.2.2,對於該版本,不應引發此錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM