- Version: v12.12.0 (also tried v10.16.3)
- Platform: Windows x64
- Subsystem: module
Windows is using case-insensitive file systems. So essentially myModule.js and MYMODULE.JS are the same files.
Node.JS require is using caching so if you are trying to resolve a module the second time you are getting the same instance of it.
But this cache is case-sensitive so we are getting
require('myModule') === require('myModule');
require('myModule') !== require('MYMODULE');
You may say, that it is by design but I found an important usecase that you should consider.
There are situations when __dirname and process.cwd() are the same but with different cases. So child dependencies would be loaded independently without caching and that can introduce very weird and difficult to identify issues.
I've prepared a demo gist to show the problem
For more details, see my blogpost
Windows is using case-insensitive file systems. So essentially myModule.js and MYMODULE.JS are the same files.
Node.JS
requireis using caching so if you are trying to resolve a module the second time you are getting the same instance of it.But this cache is case-sensitive so we are getting
You may say, that it is by design but I found an important usecase that you should consider.
There are situations when
__dirnameandprocess.cwd()are the same but with different cases. So child dependencies would be loaded independently without caching and that can introduce very weird and difficult to identify issues.I've prepared a demo gist to show the problem
For more details, see my blogpost