Daizc
count.articles52
count.tags25
count.categories3
Angular初学排坑日记(二) windows软链接惨案

Angular初学排坑日记(二) windows软链接惨案

上文讲到已经成功创建了Angular项目,现在总得跑下DEMO来试试水吧,于是打开webstorm导入项目,单击播放键。好家伙,新错误来了。

1
2
3
4
5
6
7
8
9
10
11
12
13
D:\Users\Link\WebstormProjects\angularDemo\src\polyfills.ts - Error: Module build failed (from D:\Users\Link\WebstormPro
ojects\angularDemo\node_modules\@ngtools\webpack\src\ivy\index.js):
Error: D:\Users\Link\WebstormProjects\angularDemo\src\polyfills.ts is missing from the TypeScript compilation. Please ma
ake sure it is in your tsconfig via the 'files' or 'include' property.
at D:\Users\Link\WebstormProjects\angularDemo\node_modules\@ngtools\webpack\src\ivy\loader.js:60:26



** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **


× Failed to compile.
√ Browser application bundle generation complete.

编译失败,但浏览器启动成功。弹出一个明晃晃的Cannot GET /

仔细看了下报错,但完全没明白这个提示的意思,感觉就是说src\polyfills.ts没找到,所以ts编译失败啥的,让我检查tsconfig里是否有配置files或者include属性。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
},
"files": [
"src/main.ts",
"src/polyfills.ts"
],
"include": [
"src/**/*.d.ts"
]
}

但是很遗憾的是,配置里都有配,但这个问题还是出现了,于是开始google。

总而言之就是windows软链接惹的祸,angular需要在配置里设置保留逻辑链接才能正常的读到文件。
起因是我在装系统时为了节约C盘的空间,将C:\User\Link这个目录通过Symlink的方式挂载到了D盘导致触发了这个报错。

copyright.author:Daizc
copyright.permalink:https://note.bequick.run/Angular%E5%88%9D%E5%AD%A6%E6%8E%92%E5%9D%91%E6%97%A5%E8%AE%B0%EF%BC%88%E4%BA%8C%EF%BC%89windows%E8%BD%AF%E9%93%BE%E6%8E%A5%E6%83%A8%E6%A1%88/
版权声明:本文采用 CC BY-NC-SA 3.0 CN 协议进行许可