2017-09-13 85 views
1

听到关于Angular AOT模式的太多内容后,我想给它一个尝试。所以,我们将我们的应用程序迁移到了Angular v4.1.2,并进行了所有必需的更改。当我尝试在我的webpack配置文件中使用ngc-webpack插件配置的以下部分运行AOT模式构建时,我陷入了一些未知错误。AOT清理加载程序错误,无法使用AOT模式构建Angular应用程序

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清洁-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) 

我被困在这个错误现在已经相当一段时间,无法弄清楚什么是我做的WRO的事NG。请有人帮我在这里。

+0

您正在使用哪种打字稿版本? – monica

+0

当然,我意识到有人已经降级了打字稿版本,所以我将其升级到了2.2.2并且工作。 –

回答

0

你可以检查版本是否是2.2.2,它不应该为这个版本抛出这个错误。

相关问题