`another module with an equal name` warning – need more info

There is warning sometimes:

(webpack)/buildin/module.js
There is another module with an equal name when case is ignored.
This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
Rename module if multiple modules are expected or use equal casing if one module is expected.

/Code/app/~/webpack/buildin/module.js
There is another module with an equal name when case is ignored.
This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
Rename module if multiple modules are expected or use equal casing if one module is expected.

it would useful to have additional info what does this warning mean and what causes it.
In my case this is caused by linked packages that require module with the same name from different locations. But it would be nice to have this conflicting module name in the warning message and probably some additional some details.

Author: Fantashit

7 thoughts on “`another module with an equal name` warning – need more info

  1. So it’s actually caused by the fact that Node’s builtin functions aren’t consistent in what case they use for the drive letters on Windows. __filename, __dirname, and require.resolve return it in upper case (D:\dev\foo) whereas path.resolve and process.cwd in lower (d:\dev\foo).

    webpack-dev-server uses require.resolve here, which leads to the bug I described above.

    I think the best workaround here would be to make webpack internally consider D:\file.js and d:\file.js exactly same files.

  2. @thorn0 This was it, thanks! It’s the weirdest thing, though. I usually type cd **c:**dev\projectname into my console and get going. running dev-server or whatever. Typing cd **C:**dev\projectname fixed it. I didn’t even know it made a difference.

  3. @whitecolor It turns out it makes a difference for Node on Windows whether you run cd d:\foo or cd D:\foo before running Node. So just use upper case everywhere in your paths. :trollface:

  4. Using a capital letter in the drive of the path works for me. C:\ rather than c:
    Either change Your “start in” path, or from console:
    cd C:\mypath (the drive will not change)
    d: (switch to another drive)
    c: (switch back, and it’s changed)

    As this is just a hack, it would be nice if it was fixed to be case insensitive in the core.

  5. Here is an emergency monkey patch:

    E.g. top of your webpack.dev.server.js:

    var WarnCaseSensitiveModulesPlugin = require('webpack/lib/WarnCaseSensitiveModulesPlugin');
    WarnCaseSensitiveModulesPlugin.prototype.apply = function () {};
    
  6. To beat a dead 🐴

    I had this issue on Mac OSX where I inadvertently imported a file from a location and capitalized the directory name i.e. import ReactTableWrapper from '../../Components/ReactTableWrapper'. It was happily imported however my directory name is components, not Components.

    After I realized this, I looked more carefully at the warnings which happily tell you there’s a case difference i.e. WARNING in ./src/containers/App/actions.js WARNING in ./src/Containers/App/actions.js <– see the difference? I fat fingered the folder name again and made it proper-case instead of lowercase. After doing a case sensitive grep to find the offending imports, 💯 of those warnings are gone! 🙂 It would be better if there was a [different?] warning showing you in which file the potentially bad import was in, rather than [or in addition to] telling me which module was imported > 1 x.

Comments are closed.