Can I force node.js require to be case sensitive? Can I force node.js require to be case sensitive? linux linux

Can I force node.js require to be case sensitive?


If you use webpack, check out https://github.com/Urthen/case-sensitive-paths-webpack-plugin

Just installed it for our dev builds. Would have saved us from taking prod down multiple times... Which, if you're on this question, is already probably happening 😉

Install

npm install --save-dev case-sensitive-paths-webpack-plugin

Usage

const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');const webpackConfig = {    plugins: [        new CaseSensitivePathsPlugin(),        // other plugins ...    ],    // other webpack config ...};


Since your hfs filesystem is not case sensitive, lookups for 'fileName' will match 'filename' at OS lib level, and therefore node.js will behave the same. So by definition there is no workaround.

But at the price of a reformating you can change your fs format to use hfs case sensitive.

http://www.coriolis-systems.com/iPartition.php is mentioned in this thread : https://superuser.com/questions/380330/mac-convert-from-case-sensitive-to-case-insensitive-file-system


The bulletproof answer is to reformat your MacOS filesystem to be case-sensitive but this is of course extremely inconvenient. Instead have a look at this answer to a related question, which describes a very elegant solution for this problem on MacOS, which is to create a virtual case sensitive partition, and perform all development work on that:How do I commit case-sensitive only filename changes in Git?