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

require(" issue in Win 10 combined with Node LTS 8.9.0 & 8.9.3 #17611

Closed
Laro88 opened this issue Dec 11, 2017 · 3 comments
Closed

require(" issue in Win 10 combined with Node LTS 8.9.0 & 8.9.3 #17611

Laro88 opened this issue Dec 11, 2017 · 3 comments
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. module Issues and PRs related to the module subsystem.

Comments

@Laro88
Copy link

Laro88 commented Dec 11, 2017

I have had the "interesting" experience instantiating a module twice using require as usual.

In almost all files in the project i had
var dbioSec = require("../dbiosec.js") however in one file i mistyped and wrote
var dbioSec = require("../dbioSec.js")

This results in a second initialization (console.trace in module global init results in double stacktrace and partial functionality in the application.

VSCode debugger only triggers once, however there are two -or perhaps 1,15 instance :-) since something seems shared accordingly and some module scoped vars certainly behaves interesting.

I believe that this odd behaviour compared to 6.x where the problem did not manifest itself - or that I did not hit it in the unit testing.
A "fix" could be linter / load warning, application crash or whatever - almost anything will be better than keep running :-)

@bnoordhuis bnoordhuis added duplicate Issues and PRs that are duplicates of other issues or PRs. module Issues and PRs related to the module subsystem. labels Dec 11, 2017
@bnoordhuis
Copy link
Member

Thanks for the bug report but that's the documented behavior and it's always been thus. From https://github.com/nodejs/node/blob/v9.2.1/doc/api/modules.md#module-caching-caveats:

Additionally, on case-insensitive file systems or operating systems, different resolved filenames can point to the same file, but the cache will still treat them as different modules and will reload the file multiple times. For example, require('./foo') and require('./FOO') return two different objects, irrespective of whether or not ./foo and ./FOO are the same file.

I'm closing this out as a duplicate of #5143, #11889 #14019, #14084, #16731 and quite probably others. See the discussion in those issues if you're interested why we can't / won't change that.

@Laro88
Copy link
Author

Laro88 commented Dec 11, 2017

@bnoordhuis Is there room for a warning in node.js?
pseudo code
if(isWindows && cache.hasOwnPorperty(modulename.toLower) then console.warn ("A U sure you wish to play the casing game on windows?"

@bnoordhuis
Copy link
Member

There is not, I'm afraid. Case sensitivity is a property of the file system, not the operating system. Determining whether a file path is treated case-sensitive or not is a Hard Problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. module Issues and PRs related to the module subsystem.
Projects
None yet
Development

No branches or pull requests

2 participants