无法打开“文件名":找不到文件(文件:<错误的文件路径>/文件名) [英] Unable to open &#39;filename&#39;: File not found (file:&lt;wrong file path&gt;/filename)

查看:56
本文介绍了无法打开“文件名":找不到文件(文件:<错误的文件路径>/文件名)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从另一个开发人员那里继承了一个项目,它有一个奇怪的怪癖,我不明白.这是一个 Angular 项目.

I have inherited a project from another developer, and it has an odd quirk I don't understand. It'is an Angular project.

当我加载 index.html 文件时,我在文件上 ctrl+click 时出现错误:

When I load the index.html file, and I ctrl+click on a file, I get error:

无法打开文件名":找不到文件.错误.

Unable to open 'filename': File not found. error.

这对我来说没有多大意义,因为 index.html 的路径相对于目标文件是正确的.

This doesn't make much sense to me because the path to index.html is correctly relative to the destination file.

我的 index.html 文件在:

My index.html file is in:

C:\FrontEnd\login-component\app\index.html

我的 app.js 文件位于:

My app.js files is in:

C:\FrontEnd\login-component\app\js\app.js

在 index.html 文件中指向它的链接是:

And the link to it in the index.html file is:

script src="js/app.js"

然而,弹出的错误说它在这里找不到app.js文件:

However, the error that pops up says that it can't find app.js file here:

C:\FrontEnd\login-component\js\app.js

这是真的,因为它缺少路径的应用程序"部分.

which is true, because it's missing the "app" part of the path.

试图找出问题所在,我试图删除我的 .vscode 目录并禁用我的 C# 插件,但似乎都没有任何效果.

Trying to find out what the problem is, I've tried to delete my .vscode directory and disabled my C# plugin, but neither seemed to have any effect.

奇怪的是,似乎只有一些项目表现出这种行为.有没有人对可能导致这种奇怪行为的原因以及如何解决它有任何建议?

What's stranger is it only seems to be some projects that exhibit this behavior. Does anyone have any suggestions on what could be causing this odd behavior, and how to fix it?

谢谢

推荐答案

好吧,我一直环顾四周,终于明白了.
正如我所想的,这与 VSCode 设置无关.

Okay, I kept looking around and I figured this out.
This has nothing to do with a VSCode setting, as I had thought.

在 index.html 文件中,有这么一行:

In the index.html file, there was this line:

<base href="/">

文件中的那一行,它抛弃了所有文件的相对位置.将其注释掉,链接现在可以工作,应用程序运行完全没有明显问题.

With that line in the file, it threw off the relative location for all the files. Commenting it out, the links now work, with no apparent issues with the application running at all.

这篇关于无法打开“文件名":找不到文件(文件:<错误的文件路径>/文件名)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆