Since my Mac has a case-insensitive filesystem case related typos will not be caught when running tests locally, however they fail on the build server which is running Linux.
For example: require('./mymodule')
will find ./myModule.js
when running on Lion, but not on Linux.
Since I'd like to have the tests fail locally as well in order to not break the build on the server, I'm looking for a way to make node.js require more strict in that it throws an error if it the filename is not exact (i.e. has a difference in casing).
Does anyone know of a way to accomplish this?
EDIT:
Since there seemed no good solution for this problem out there I created valiquire.
This tool validates all requires found in an entire nodejs project also ensuring that the casing is correct.
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 😉
npm install --save-dev case-sensitive-paths-webpack-plugin
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const webpackConfig = {
plugins: [
new CaseSensitivePathsPlugin(),
// other plugins ...
],
// other webpack config ...
};