简体   繁体   English

Angular 10:VScode 在某些目录的绝对路径上出错,而​​不是其他目录

[英]Angular 10: VScode errors out on absolute path for some directories, not others

Last week, VScode complained about not being able to resolve modules in every directory except my components directory.上周,VScode 抱怨无法解析除我的 components 目录之外的每个目录中的模块。 Now, it works fine for all directories except one that I created today (stores).现在,它适用于所有目录,除了我今天创建的目录(商店)。 I'm going nucking futz here.我要在这里胡说八道。 Everything compiles in Angular so it's not a TS error.一切都在 Angular 中编译,所以它不是 TS 错误。 It just seems to be that VScode can't figure out absolute paths (but somehow knows that SOME folders are 'legit')似乎 VScode 无法找出绝对路径(但不知何故知道某些文件夹是“合法的”)

I'm not doing any path aliasing (because I couldn't get THAT to work, either)我没有做任何路径别名(因为我也不能让它工作)

I've re-loaded my workspace and have restarted VScode.我重新加载了我的工作区并重新启动了 VScode。

I reinstalled VScode last week but it didn't solve the issue where only my components directory were showing errors.我上周重新安装了 VScode,但它没有解决只有我的组件目录显示错误的问题。 BUT sometime between then and now, it did start working.但是从那时到现在,它确实开始工作了。

I've upgraded to vscode 1.49.0 and the issue still persists.我已经升级到 vscode 1.49.0,问题仍然存在。

In my models folder, components folder, (and all other folders), it prompts me for pathing as I type, and lints the path fine:在我的模型文件夹、组件文件夹(以及所有其他文件夹)中,它会在我键入时提示我进行路径设置,并细化路径:
在此处输入图片说明

In my stores folder, it doesn't prompt for the path:在我的商店文件夹中,它不提示输入路径:
在此处输入图片说明

And it complains about not being able to load the module:它抱怨无法加载模块:
在此处输入图片说明

It's REALLY hard to concentrate on my project when my editor says things are broken when they're not.当我的编辑说事情已经坏了,而实际上并没有坏的时候,我真的很难专注于我的项目。 Does VScode cache workspace directory structures so it knows whether a path is kosher? VScode 是否缓存工作区目录结构,以便它知道路径是否符合 kosher? and if so, can I manually refresh that cache when I add a new directory, if VScode isn't going to bother doing it for me?如果是这样,如果 VScode 不想为我做这件事,我可以在添加新目录时手动刷新该缓存吗?

好吧,我遇到了这个问题,所以我建议您不要在路径中直接调用 'src',而是建议您使用 '../../' 目录浏览。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM