在听了很多关于Angular AOT模式之后,我想试一试。因此,我们将应用程序迁移到Angular v4.1.2,并进行了所需的所有必要更改。当我尝试使用AOT模式运行构建时,我的webpack配置文件中包含以下部分ngc-webpack插件配置,我遇到了一些未知错误。
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)
我现在坚持这个错误很长一段时间,无法弄清楚我做错了什么。请有人帮帮我。
答案 0 :(得分:0)
您可以检查版本是否为2.2.2,不应该为此版本引发此错误。