fbjs icon indicating copy to clipboard operation
fbjs copied to clipboard

ERROR in ./node_modules/fbjs/lib/setImmediate.js Module not found: Error: [CaseSensitivePathsPlugin]

Open mkaisercross opened this issue 5 years ago • 3 comments

Case sensitivity issue from fbjs causing build to fail.

ERROR in ./node_modules/fbjs/lib/setImmediate.js Module not found: Error: [CaseSensitivePathsPlugin] /Users/KaisMi01/sdev/capture-utility/node_modules/fbjs/lib/setimmediate.js does not match the corresponding path on disk setImmediate.js.

mkaisercross avatar May 28 '19 15:05 mkaisercross

Got the same issue when running webpack on a project using draft-js which has fbjs as a dependency under windows.

leschekfm avatar Jun 28 '19 11:06 leschekfm

This issue still exists, but it is likely caused not by fbjs itself. What is setImmediate.js intended to do is to re-export setImmediate function from setimmediate npm package (note difference in "i" casing). The latest contains setImmediate.js module (with capital "i" again). So, when you require('setimmediate'), you actually reference to node_modules/setimmediate/setImmediate.js, which is the problem pointed out by Webpack CaseSensitivePathsPlugin, probably a "false positive" in this case.

It seems like an issue not to be fixed soon, as it does not create a big problem except with Webpack, so we have two options:

  1. Disable CaseSensitivePathsPlugin which could to be not a preferred solution.
  2. Replace import('setimmediate') with import('setImmediate') in fbjs — CaseSensitivePathsPlugin is satisfied while npm still resolves a package correctly. This can be achieved with simple Webpack loader.

webpack.fbjs.loader.js

module.exports = function(source) {
    return source.replace(
        /require\((['"])setimmediate(['"])\)/g,
        "require($1setImmediate$2)"
    );
};

webpack.config.js

config.module.rules.push({
    test: /\.js$/,
    include: /node_modules/,
    use: path.resolve(__dirname, 'webpack.fbjs.loader.js')
});

vyprichenko avatar Apr 21 '21 12:04 vyprichenko

This didn't work for me, I am working on the SPFx React TS project, and I created the file webpack.fbjs.loader.js and added the code In my webpack.extend.js file in fast-serve folder. But nothing happened. Please help me on this, using older version of spfx.

Aditya-Ace avatar Sep 14 '23 22:09 Aditya-Ace