New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File differs from already included file only in casing: correct casing but relative path #25460
Comments
This looks like a bug, but we'll need some way to reproduce it. Do you have a zip file or repo or description of the files we could use? |
As it turns out, the issue was with a third party module, tsify. Our project was using 1.0.1, and |
I had same issue with one of my component import. I component directory name was historical with same "h" I was trying to import it with capital "H". It should be " |
Thanks @aaybhangu! |
Hi, I am still facing this issue with - error TS1149: File name 'src/models/headers/userRole.ts' differs from already included file name 'src/models/headers/UserRole.ts' only in casing. |
I am also facing the same issue. |
I stumbled across this exact same error recently. hope this helps |
I came across this same issue
For my case, somewhere in the directory, the errors were happening, was changed...? So I had to do the following to fix them all.
then it should fix the problem. |
I am getting this bug after renaming a file from the camelCase to uppercase all first letters |
In my case, I used to create a file named So I use VSCode |
I have the same issue, and just discovered that for some reason, in some ts file it is called using a capitalize letter, then I renamed it for lowercase and it works. You can try also removing this model ts file and creating again with angular-CLI. |
Changing case results in exception on updateOpen command. Note how file is opened with different case and closed with original casing in same command.
|
This issue seems to be more involved than just checking root file names. When reusing program there is another test case that fails which is simple program reuse test: it("forceConsistentCasingInFileNames works when renaming file with different casing", () => {
const loggerFile: File = {
path: `${projectRoot}/logger.ts`,
content: `export class logger { }`
};
const anotherFile: File = {
path: `${projectRoot}/another.ts`,
content: `import { logger } from "./logger"; new logger();`
};
const tsconfig: File = {
path: `${projectRoot}/tsconfig.json`,
content: JSON.stringify({
compilerOptions: { forceConsistentCasingInFileNames: true }
})
};
const host = createWatchedSystem([loggerFile, anotherFile, tsconfig, libFile, tsconfig]);
createWatchOfConfigFile(tsconfig.path, host);
checkOutputErrorsInitial(host, emptyArray);
host.writeFile(anotherFile.path, anotherFile.content.replace("./logger", "./Logger"));
host.runQueuedTimeoutCallbacks();
checkOutputErrorsIncremental(host, [
createCompilerDiagnostic(Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, loggerFile.path, `${projectRoot}/Logger.ts`),
]); // Currently the errors are not reported in watch mode but will be reported if program is created from scratch.
}); |
Yep, I'm having this same issue and none of the previously-stated fixes/workarounds do anything to help. In my case, the message is:
|
A restart of the Typescript-Server will suffice. VSCode restart is overkill. In VSC on OSX: |
With webstorm You need to invalide and clear the cache : |
The shortest and best solution I found is. Just remove that word from that causing casing problems. I removed of from the file name. And the compilers compiled it correctly. Then later I renamed by my desired case Also, keep in mind the git. |
I had the same problem with import, after a rename a file from "a" to "A", i just restarted the vs code and then it works. |
I had the same problem. VSCode restart and setting "forceConsistentCasingInFileNames": false can't help me. error info:(just differ in disk symbol) why? |
Solved! Everything was fine locally on mac, but i was getting this error on my Jenkins server. The problem was simply that locally the filename was 'quote.ts' but within my remote git repo it was 'Quote.ts'. How the problem came about And so when Jenkins pipeline ran, it was pulling down 'Quote.ts' when it was being referenced as '../../quote.ts' - which results in the error. How i solved it
Boom Bam! Hope this helps someone |
Had a similar issue that generated around 100 of these errors. Didn't read them all to closely as they all seemed to have the same root problem. Had recently switched to running node in WSL2 that I took for granted was the cause of the issue. After 2 hours without success I actually went through the whole list and found one example where there was an actual bug. import { FooInterface } from '../Foo'; // should be '../foo' I changed it to lowercase, reloaded vscode, rebuilt it and all the errors went away. What I think happend is that ts tried to import the incorrect path ('Foo' instead of 'foo') and then cached the result and tried to use the incorrect cached path when processing the rest of the code. Hopefully this helps someone out there! |
i just restart my ide then the error is gone |
just make a same object in component, and start your ng, after running successfully, then remove object and import your link, |
this just happened to me, it's an ongoing issue that hasn't been solved. It happens whenever I change the casing of a directory name and try to commit the change. Git doesn't recognize change in casing for a directory name. |
+1......but WHYYYYYYYY |
I just faced the problem. It turned out that when I tried to import it using vscode, VSCode used the previous file name and directory name. So I modified it and after running |
@ninjavang you helped me! Had the same issue happening with my gitlab ci/cd pipeline. Turns out when i went to the remote branch and checked the file's path, there were two versions of the file, each in their case sensitive version. I deleted the version unwanted on the remote, copied the file locally, pulled the remote down, refreshed my VS Code, and re-added the file. It worked! Thanks for the help! |
So tried all the restart etc without success... Turns out the issue is that if another file in the project references the old casing then every other file which attempts to use the new (correct) casing will fail. So ensure that the file's casing has been changed in every file. That is so a bug. |
At version 4.1.3 still reproduced. |
Experienced this yesterday when renaming files and methods. WebStorm got lost and was displaying this even after I had fixed everything. A good old cmd+q and restart of WebStorm fixed it. 🤷 |
webstorm encountered this problem . Restart TS Server not working |
|
The following command fixed things up for me:
|
ctrl+shift+p: restart eslint server |
The mentions of this being Windows-only might be related to the drive letter, as I just had this issue with this message:
Weirdly enough, in my case the cause was that I had the mentioned |
Just reload the window. |
This is turning into a support thread but this is not a support forum. If you have a reproducible specific defect, please file a new issue following the template. If you have a configuration problem, please use an appropriate support forum such as StackOverflow or Discord. |
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?
It compiles just fine on Mac and Linux, but throws this error on Windows.
The text was updated successfully, but these errors were encountered: