Skip to content
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

Import are case insensitive in window 10 #36968

Closed
GrosSacASac opened this issue Jan 16, 2021 · 6 comments
Closed

Import are case insensitive in window 10 #36968

GrosSacASac opened this issue Jan 16, 2021 · 6 comments
Labels
libuv Issues and PRs related to the libuv dependency or the uv binding. windows Issues and PRs related to the Windows platform. wontfix Issues that will not be fixed.

Comments

@GrosSacASac
Copy link
Contributor

  • Version:15.2.1
  • Platform:window 10
  • Subsystem:IMPORT

What steps will reproduce the bug?

a.js

import {b} from "./B.js";

b.js

export {b};
const b = 10;

package.json

{
  "version": "1.0.0",
  "type": "module",
  "private": true
}

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

B.js not found (Uppercase)

What do you see instead?

no errors

Additional information

It creates error on linux

@devsnek
Copy link
Member

devsnek commented Jan 16, 2021

this is because the filesystem on your windows machine is case insensitive. not much we can do about that.

@aduh95
Copy link
Contributor

aduh95 commented Jan 16, 2021

There are quite a lot of layers between Node.js ESM loader and the actual file on your hardware. The gist of it is that it relies on the Windows API, which is case insensitive by default. If you check the Windows API documentation, you can see there is a FILE_FLAG_POSIX_SEMANTICS flag that does enable case sensitivity in Windows. As the documentation indicates, this option could break other applications written and I guess that's why libuv doesn't use it.

I suggest to open an issue on libuv/libuv (the library Node.js relies on for FS related operations) asking for this flag to be enabled. They'll know if that's something possible without breaking the ecosystem.

@aduh95 aduh95 added the libuv Issues and PRs related to the libuv dependency or the uv binding. label Jan 16, 2021
@GrosSacASac
Copy link
Contributor Author

May I suggest, do not use libuv fs for imports and instead implement something more strict.

I feel like this will create a lot of "but in works on my machine !" - type of situation especially in team where some developers have Linux and some have windows machines. And it is not only for backend since a lot of Front End tools use NodeJs as well nowadays.

@aduh95
Copy link
Contributor

aduh95 commented Jan 16, 2021

do not use libuv fs for imports and instead implement something more strict

Well, you are very welcome to open a PR, but I doubt it's a reasonable way of solving your issue. Also, there are filesystems out there which are case insensitive (E.G.: HFS+), and there is no way around that on the software level.

@j1mmie
Copy link

j1mmie commented May 29, 2024

Sorry for the necro and somewhat off-topic comment. But for Typescript users who come here via Google, there's a config option to detect similar imports that have mismatched casing:

forceConsistentCasingInFileNames in TSConfig

Not perfect, but still helpful. There's a long-running issue over at the Typescript repo that seems to be making some progress though: microsoft/TypeScript#21736

@RedYetiDev RedYetiDev added wontfix Issues that will not be fixed. windows Issues and PRs related to the Windows platform. labels May 29, 2024
@RedYetiDev
Copy link
Member

RedYetiDev commented May 29, 2024

Well, you are very welcome to open a PR, but I doubt it's a reasonable way of solving your issue. Also, there are filesystems out there which are case insensitive (E.G.: HFS+), and there is no way around that on the software level.

It seems this is working as intended, so I'm closing this issue, but if anyone disagrees, please re-open

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libuv Issues and PRs related to the libuv dependency or the uv binding. windows Issues and PRs related to the Windows platform. wontfix Issues that will not be fixed.
Projects
None yet
Development

No branches or pull requests

5 participants