'File name differs from already included file name only in casing' on relative path with same casing

80,187

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,
    ...
  }
}
Share:
80,187

Related videos on Youtube

zuddsy
Author by

zuddsy

Updated on March 20, 2022

Comments

  • zuddsy
    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
      27px over 3 years
      In my case it was the case, (used uppercase instead of lower case)
  • kkost
    kkost over 5 years
    what is tisfy ?
  • katwekibs
    katwekibs over 4 years
    Updating what? please provide more info on what you updated
  • nos codemos
    nos codemos over 3 years
    in case anyone else has the same problem in Vue, I can vouch this solves the error, at least in Vue3.
  • Steve
    Steve over 3 years
    This 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
    emcee22 over 3 years
    Same for me. For some reason duplicated files were only present in github and heroku was failing on build with this error. Thx
  • Jack Barry
    Jack Barry about 3 years
    Usually for stuff like this Reload Window works for me, but in this case a full restart of VS Code was needed
  • Fabricio
    Fabricio about 3 years
    In my case I just renamed the file then renamed it back again
  • Barry Michael Doyle
    Barry Michael Doyle almost 3 years
    You're literally my hero. Thank you!
  • SujithaW
    SujithaW almost 3 years
    I had to do a full restart
  • Ali Afsahnoudeh
    Ali Afsahnoudeh almost 3 years
    Same here, renaming the file and then make it back again worked for me as well. tnx
  • Igiri David
    Igiri David over 2 years
    This 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
    Danny over 2 years
    Same, renaming the file. Weird issue.
  • Birhan Nega
    Birhan Nega over 2 years
    This answer is the correct one.
  • testingtestinganyone
    testingtestinganyone over 2 years
    thats the one. thanks
  • AmerllicA
    AmerllicA over 2 years
    @novonimo, You're my hero too, thanks bro!
  • user2721180
    user2721180 over 2 years
    In 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
    Aidin over 2 years
    for 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
    Luke Savefrogs over 2 years
    Same... Restarting did the trick
  • zt1983811
    zt1983811 over 2 years
    Yep it works thanks HERO LOL
  • Filip Górczyński
    Filip Górczyński about 2 years
    What I've just discovered, removing extension in component import statement also helps. Can't figure it out why, yet.
  • Darky WC
    Darky WC about 2 years
    I did the same thing as op, but for Vetur, it does not go away even after I restart vscode
  • Darky WC
    Darky WC about 2 years
    I 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
    al.koval about 2 years
    it's work fo me, tnx
  • Chim
    Chim almost 2 years
    I got the same problem in test files (using jest) and 'node ./node_modules/jest/bin/jest.js --clearCache' solved the problem.