zud*_*dsy 16 javascript windows compiler-errors typescript
错误TS1149:文件名'C:/Project/frontend/scripts/State.ts'仅在大小写方面与已包含的文件名'../frontend/scripts/State.ts'不同。
我已经三遍检查了参考资料中的大小写,实际文件中的大小写也正确。据我所知,这仅仅是因为相对路径使用了不正确的大小写,还是仅由于相对路径本身?
事实是,它在Mac和Linux上可以正常编译,但在Windows上会引发此错误。
如果有帮助,请forceConsistentCasingInFileNames在tsconfig中启用它,然后使用tsify进行编译。
Pau*_*erg 52
对我来说,当一个文件被迅速从改名发生问题someFile.ts到SomeFile.ts。重新启动我的 IDE (Visual Studio Code) 使警告消失。
Rus*_*kin 22
你需要禁用"forceConsistentCasingInFileNames"的在tsconfig.json文件中。
所以你应该有这样的东西:
{
"compilerOptions": {
...
"forceConsistentCasingInFileNames": false,
...
}
}
Run Code Online (Sandbox Code Playgroud)
Mar*_*lin 20
就我而言,错误是在import语句中。导入声明使用大写字母而不是小写字母,该字母在Windows中的开发过程中有效,但在编译生产时则无效。
错误:
import {SomeClass} from '/some/path/SomeClass.ts';
Run Code Online (Sandbox Code Playgroud)
正确:
import {SomeClass} from '/some/path/someClass.ts';
Run Code Online (Sandbox Code Playgroud)
tte*_*ple 18
重新启动 VS Code IDE 对我不起作用,我不想更改配置文件。这些是对我有用的步骤来解决这个问题:
它一定是 VS Code 中的某种缓存问题
nov*_*imo 12
2021 年更新
这是我的IDE中发生的有线错误,但可以通过两个简单的步骤轻松完成:
rename your file (not component) to another name and once again back to your original name.
例子:
> src
> components
> myFile.js
Run Code Online (Sandbox Code Playgroud)
首先,将 myFile.js 重命名为另一个名称(任何名称),例如 temp.js:
myFile.js ----> temp.js
Run Code Online (Sandbox Code Playgroud)
第二,回到原来的名字,
temp.js ----> myFile.js
Run Code Online (Sandbox Code Playgroud)
它也适用于*.ts *.tsx *.js *.jsx扩展。
Fra*_*mes 10
重启你的 TS 服务器还不够!
截至 2023 年,我找到了重现该问题的一致方法。只要您仍然有imports 指向错误的路径,就会发生此错误!(更名后)
// Wrong path, but same "Already included file name" error
import { Home } from './home';
// CORRECT path, but same "Already included file name" error
import { Home } from './Home'; // <- new path
Run Code Online (Sandbox Code Playgroud)
修复所有导入路径并重新启动 TS 服务器(在 VS Code 上,按 F1 > Restart TS server)
TS 团队绝对应该致力于改进此错误消息:)
好吧,只需要在这里添加我的“解决方案”,因为它与其他解决方案不同。错误消息清楚地说明了它在哪里看到错误。它是已重命名的目录的外壳(从 Utils -> utils)。尽管它在所有地方都被正确重命名,但我仍然收到错误。我的解决方案是再次将其重命名为 utils2(为什么不呢,呵呵)。之后一切正常
| 归档时间: |
|
| 查看次数: |
9247 次 |
| 最近记录: |