gpt4 book ai didi

Angular 5 webpack编译错误

转载 作者:太空狗 更新时间:2023-10-29 17:19:43 28 4
gpt4 key购买 nike

升级到 Angular 5 和 Cli 1.5 后,在 ng serve 上出现错误:

ERROR in ./node_modules/@stomp/ng2-stompjs/index.ts
Module build failed: Error: ...\project\node_modules\@stomp\ng2-stompjs\index.ts is not part of the compilation output. Please check the other error messages for details.
at AngularCompilerPlugin.getCompiledFile (...\project\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:629:23)
at plugin.done.then (...\project\node_modules\@ngtools\webpack\src\loader.js:467:39)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
@ ./src/app/app.module.ts 27:0-63
@ ./src/main.ts
@ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts

我尝试将 include 添加到我的 tsconfig.app.json 中,它看起来像这样:

{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"baseUrl": "",
"types": []
},
"include": [
"../node_modules/@stomp/**/*.ts"
],
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}

我尝试重新运行 ng serve 我得到另一个错误:

    ERROR in ./src/main.ts
Module build failed: Error: ...project\chatAngular4\src\main.ts is not part of the compilation output. Please check the other error messages for details.
at AngularCompilerPlugin.getCompiledFile (...project\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:629:23)
at plugin.done.then (...project\node_modules\@ngtools\webpack\src\loader.js:467:39)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
@ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts
ERROR in ./src/polyfills.ts
Module build failed: Error: C:\Users\MEP2\Desktop\chatAngular4\src\polyfills.ts is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (...project\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:624:23)
at plugin.done.then (...project\node_modules\@ngtools\webpack\src\loader.js:467:39)
at <anonymous>
@ multi ./src/polyfills.ts

这看起来需要某种通用的解决方法。有什么想法吗?


更新

更新所有包到最新版本后,问题消失

最佳答案

尝试 ng serve --preserve-symlinks

在大多数情况下,它对当前版本的 Angular 有帮助。

或者干脆不要从符号链接(symbolic link)的文件夹中运行 ng serve。从真实的运行它。

期待他们修复它。

关于Angular 5 webpack编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47122472/

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