gpt4 book ai didi

javascript - AOT 清理加载程序出错,无法使用 AOT 模式构建 Angular 应用程序

转载 作者:行者123 更新时间:2023-11-28 04:11:58 28 4
gpt4 key购买 nike

在听说了这么多有关 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% 后,并使用很棒的 typescript 加载器成功编译时,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,该版本不应抛出此错误。

关于javascript - AOT 清理加载程序出错,无法使用 AOT 模式构建 Angular 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46193462/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com