'File name differs from already included file name only in casing' on relative path with same casing
Solution 1
The answer was that we were using tisfy 1.0.1, when forceConsistentCasingInFileNames
wasn't supported until 4.0.0. Updating fixed the issue.
Solution 2
For me, the issue occurred when a file was quickly renamed from someFile.ts
to SomeFile.ts
. Restarting my IDE (Visual Studio Code) made the warning go away.
Solution 3
In my case, the error was in the import statement. The import statement had a capital letter instead of small letter, which worked during develop in Windows, but not when compiling for production.
wrong:
import {SomeClass} from '/some/path/SomeClass.ts';
correct:
import {SomeClass} from '/some/path/someClass.ts';
Solution 4
UPDATE 2021
That's a wired error that occurred in my IDE, but it can be simply done with two simple steps:
rename your file (not component) to another name and once again back to your original name.
Example:
consider we have a myFile.js
file in the components
directory:
> src
> components
> myFile.js
First
Rename myFile.js
into another name (anything) like temp.js
:
myFile.js ----> temp.js
Second
back to its original name,
temp.js ----> myFile.js
It's also work fine with *.ts *.tsx *.js *.jsx
extensions.
Solution 5
You need to disable the "forceConsistentCasingInFileNames"
in the tsconfig.json
file.
So you should have something like that:
{
"compilerOptions": {
...
"forceConsistentCasingInFileNames": false,
...
}
}
Related videos on Youtube
zuddsy
Updated on March 20, 2022Comments
-
zuddsy about 2 years
Error TS1149: File name 'C:/Project/frontend/scripts/State.ts' differs from already included file name '../frontend/scripts/State.ts' only in casing.
I've triple checked the casing in our references and the actual files have the correct casing as well. As far as I can tell, this is solely because the relative path uses incorrect casing, or perhaps it's just because of the relative path itself?
The thing is, it compiles just fine on Mac and Linux, but throws this error on Windows.
If it helps,
forceConsistentCasingInFileNames
is enabled in the tsconfig, and we're using tsify to compile.-
27px over 3 yearsIn my case it was the case, (used uppercase instead of lower case)
-
-
kkost over 5 yearswhat is tisfy ?
-
katwekibs over 4 yearsUpdating what? please provide more info on what you updated
-
nos codemos over 3 yearsin case anyone else has the same problem in Vue, I can vouch this solves the error, at least in Vue3.
-
Steve over 3 yearsThis was the case for me. I had app.js and App.test.js and was getting this error when importing from app.js- 'app.js' differs from already included file name '/src/App.js' only in casing. ts(1149) Lowercasing App.test.js fixed it.
-
emcee22 over 3 yearsSame for me. For some reason duplicated files were only present in github and heroku was failing on build with this error. Thx
-
Jack Barry about 3 yearsUsually for stuff like this Reload Window works for me, but in this case a full restart of VS Code was needed
-
Fabricio about 3 yearsIn my case I just renamed the file then renamed it back again
-
Barry Michael Doyle almost 3 yearsYou're literally my hero. Thank you!
-
SujithaW almost 3 yearsI had to do a full restart
-
Ali Afsahnoudeh almost 3 yearsSame here, renaming the file and then make it back again worked for me as well. tnx
-
Igiri David over 2 yearsThis actually works. Have you any idea why? This has to go down as one of the weirdest bugs to ever walk this earth, lol.
-
Danny over 2 yearsSame, renaming the file. Weird issue.
-
Birhan Nega over 2 yearsThis answer is the correct one.
-
testingtestinganyone over 2 yearsthats the one. thanks
-
AmerllicA over 2 years@novonimo, You're my hero too, thanks bro!
-
user2721180 over 2 yearsIn my case it was ComponentName.Vue vs. ComponentName.vue (upper and lower case V). Everything appeared lowercase as intended but still the error. The steps above worked. Thanks
-
Aidin over 2 yearsfor some reason in my dev environment, it was working fine by default, but in production-build (Docker, alphine-linux) it was bugging. I found that making this flag to true, makes it consistently bugging, which is what I want. :) Thanks!
-
Luke Savefrogs over 2 yearsSame... Restarting did the trick
-
zt1983811 over 2 yearsYep it works thanks HERO LOL
-
Filip Górczyński about 2 yearsWhat I've just discovered, removing extension in component import statement also helps. Can't figure it out why, yet.
-
Darky WC about 2 yearsI did the same thing as op, but for Vetur, it does not go away even after I restart vscode
-
Darky WC about 2 yearsI did the solution similarly as op, but just reload my vscode after renaming the file. Then revert its name after reload, and it works for Vetur.
-
al.koval about 2 yearsit's work fo me, tnx
-
Chim almost 2 yearsI got the same problem in test files (using jest) and 'node ./node_modules/jest/bin/jest.js --clearCache' solved the problem.