Skip to content

Instantly share code, notes, and snippets.

@mnaoumov
Last active October 18, 2019 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mnaoumov/debe6db18a0f3a568d1dc4d23df4b499 to your computer and use it in GitHub Desktop.
Save mnaoumov/debe6db18a0f3a568d1dc4d23df4b499 to your computer and use it in GitHub Desktop.
Windows case-insensitive file names = nightmares with Node.JS
@node "%~dp0\script.js"
module.exports = {}
mkdir C:\CaseSensitive -Force | Out-Null
copy * C:\CaseSensitive -Force | Out-Null
# works fine
Write-Host "Running from c:\CaseSensitive"
cd c:\CaseSensitive
.\build.cmd
# fails
Write-Host "Running from c:\caseSENSitive"
cd c:\caseSENSitive
.\build.cmd
const myModulePath1 = __dirname + '/myModule';
const myModule1 = require(myModulePath1)
myModule1.myFunction = () => {};
const myModulePath2 = process.cwd() + '/myModule';
const myModule2 = require(myModulePath2);
myModule2.myFunction(); // Fails here
console.log('Works fine');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment