Webpack There are multiple modules with names that only differ in casing

天大地大妈咪最大 提交于 2019-12-20 04:19:04

问题


I have something like this:

WARNING in C:/Data/.../letsTest.jsx
There are multiple modules with names that only differ in casing.
This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
Use equal casing. Compare these module identifiers:
* C:\Data\...\node_modules\babel-loader\lib\index.js?presets[]=es2015&presets[]=react&presets[]=stage-0&presets[]=stage-2!C:\Data\...\letsTest.jsx
    Used by 4 module(s), i. e.
    multi C:/Data/Doc/13/13080801/LetsTest/letsTest.jsx
* C:\Data\...\node_modules\babel-loader\lib\index.js?presets[]=es2015&presets[]=react&presets[]=stage-0&presets[]=stage-2!c:\Data\...\letsTest.jsx
    Used by 1 module(s), i. e.
    C:\Data\...\node_modules\babel-loader\lib\index.js?presets[]=es2015&presets[]=react&presets[]=stage-0&presets[]=stage-2!C:\Data\...\r1HeadLearning.js           

What is the issue?


回答1:


Eventually, I found the answer. It was a Windows issue. It was necessary to change the absolute path in C:\Data...\r1HeadLearning.js from

c:\Data\...\letsTest.jsx

to

C:\Data\...\letsTest.jsx



回答2:


From Contributing.md in create-react-app:

The scripts in tasks folder and other scripts in package.json will not work in Windows out of the box. However, using Bash on windows makes it easier to use those scripts without any workarounds.

so, the easier way is to just install Bash and npm install there. the steps are:

Install Bash on Ubuntu on Windows

A good step by step guide can be found here

Install Node.js and yarn

Even if you have node and yarn installed on your windows, it would not be accessible from the bash shell. You would have to install it again. Installing via nvm is recommended.

Line endings

By default git would use CRLF line endings which would cause the scripts to fail. You can change it for this repo only by setting autocrlf to false by running git config core.autocrlf false. You can also enable it for all your repos by using the --global flag if you wish to do so.




回答3:


I just fixed the same warnings on my system, where I'm coding a Create-React-App on Windows 10. Since the Windows file system is not case sensitive, this did not prevent me from continuing to work, but it was ugly to look at on my terminal output. In investigating, none of the available answers helped me. But in a few days of ruminating on the problem I thought of a possible cause. In the recent past I had used npm a couple of times to install modules instead of my usual yarn. Since the warnings were all pointing to node-modules, I decided that could have been a mistake. So here is what I did:

  1. First I merged my develop branch into my master branch, getting everything into one branch.
  2. Next I deleted the entire node_modules folder.
  3. Then I ran yarn install to load all the package.json modules.
  4. Finally I did a yarn start, and the warnings were gone.

Maybe this will help you.




回答4:


Delete the node_modules folder and run npm install That fixed my problem



来源:https://stackoverflow.com/questions/47081843/webpack-there-are-multiple-modules-with-names-that-only-differ-in-casing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!