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.
JavaScript is a case-sensitive language. This means that language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters.
Require is not case insensitive on linux but is on windows · Issue #14019 · nodejs/node · GitHub.
NPM packages are not allowed upper case characters in their name, seemingly because unix filesystems are case-sensitive, which creates "a recipe for confusion and nonportable software".
js receives a CPU bound task: Whenever a heavy request comes to the event loop, Node. js would set all the CPU available to process it first, and then answer other requests queued. That results in slow processing and overall delay in the event loop, which is why Node. js is not recommended for heavy computation.
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 ... };
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With