javascript react 或 npm 问题:找不到模块:[CaseSensitivePathsPlugin] `...\react.js` 与磁盘 `react` 上的相应路径不匹配
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46841908/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
react or npm issue: Module not found: [CaseSensitivePathsPlugin] `...\react.js` does not match the corresponding path on disk `react`
提问by The Huff
I'm getting the following errors when I execute the npm startcommand on a react project.
npm start在 React 项目上执行命令时出现以下错误。
Failed to compile.
Error in ./~/react-scroll-pagination/dist/index.js
Module not found: [CaseSensitivePathsPlugin] `C:\Users\timhu\Dev\MongoDbStitch\PlateSpace\Web\node_modules\React\react.js` does not match the corresponding path on disk `react`.
@ ./~/react-scroll-pagination/dist/index.js 3:27-43
Error in ./~/react-scroll-pagination/dist/index.js
Module not found: [CaseSensitivePathsPlugin] `C:\Users\timhu\Dev\MongoDbStitch\PlateSpace\Web\node_modules\jQuery\dist\jquery.js` does not match the corresponding path on disk `jquery`.
@ ./~/react-scroll-pagination/dist/index.js 3:45-62
I'm new to react - but from what I can tell it's a pathing issue where npm installadds modules into the node_modules folder, all with lowercase folder names, but the compiler resolves to folder names with mixed case paths.
我是新来的反应 - 但据我所知,这是一个路径问题,npm install将模块添加到 node_modules 文件夹中,所有的文件夹名称都是小写的,但编译器解析为混合大小写路径的文件夹名称。
How do I fix this? The code is from the MongoDb Stitch PlateSpace tutorial project
我该如何解决?代码来自MongoDb Stitch PlateSpace 教程项目
Do I updated the existing code (maybe the import statements) or is it a npm or react issue?
我是否更新了现有代码(可能是导入语句),还是 npm 或 react 问题?
Thanks Tim
谢谢蒂姆
回答by Changyuan Chen
I come across the same problem.
我遇到了同样的问题。
I replaced :import React, {Component} from 'React', with :import React, {Component} from 'react'.
我用 : 替换import React, {Component} from 'React'了 : import React, {Component} from 'react'。
React is case-sensitive, so be careful and good luck.
React 区分大小写,所以要小心并祝你好运。
回答by kfroemming
You may be executing the npm install / start inside of the wrong folder. I would delete the current directory and make sure to run the install in:
您可能正在错误的文件夹中执行 npm install / start 。我会删除当前目录并确保在以下位置运行安装:
cd /stitch-examples/helloworld/react-example/
then
然后
npm install
npm start
回答by venky royal
For this error :
对于这个错误:
import React from 'react'; in your index.js file . For this error : Error in ./~/react-scroll-pagination/dist/index.js Module not found: [CaseSensitivePathsPlugin]C:\Users\timhu\Dev\MongoDbStitch\PlateSpace\Web\node_modules\jQuery\dist\jquery.jsdoes not match the corresponding path on diskjquery.
从“反应”导入反应;在您的 index.js 文件中。对于此错误:./~/react-scroll-pagination/dist/index.js 模块中的错误未找到:[CaseSensitivePathsPlugin]C:\Users\timhu\Dev\MongoDbStitch\PlateSpace\Web\node_modules\jQuery\dist\jquery .js 与 diskjquery 上的对应路径不匹配。
replace this code import React from 'react';in your index.js file .
替换import React from 'react';index.js 文件中的这段代码。
For this error :
对于这个错误:
Error in ./~/react-scroll-pagination/dist/index.js Module not found: [CaseSensitivePathsPlugin]C:\Users\timhu\Dev\MongoDbStitch\PlateSpace\Web\node_modules\jQuery\dist\jquery.jsdoes not match the corresponding path on diskjquery.
./~/react-scroll-pagination/dist/index.js 模块中的错误未找到:[CaseSensitivePathsPlugin]C:\Users\timhu\Dev\MongoDbStitch\PlateSpace\Web\node_modules\jQuery\dist\jquery.js 不匹配diskjquery 上对应的路径。
replace the code with import Jquery from './jquery';
将代码替换为import Jquery from './jquery';
Don't worry this errors will shows pretty commonly its because react is a case sensitive.
不要担心这个错误会很常见,因为 react 是区分大小写的。
回答by thehme
For anyone facing this issue who is using CRA, I was getting this error and was not understanding why. My VS Code clearly showed the correctly named file, so I decided to check in the terminal:
对于正在使用 的任何面临此问题的人CRA,我收到此错误并且不明白为什么。我的 VS Code 清楚地显示了正确命名的文件,所以我决定在终端中检查:
ls -la [path/to/file/location]
ls -la [path/to/file/location]
I then actually saw that the file was in fact lowercase!
然后我实际上看到该文件实际上是小写的!
I renamed the file via the terminal and re-listed it to confirm:
我通过终端重命名文件并重新列出它以确认:
mv src/create_page/createPage.jsx src/create_page/CreateDashboard.jsx
ls -la [path/to/file/location]
This fixed my issue, so at the end, I am not sure why this happened, maybe because my VS Code was not autosaving before I set the settings flag.
这解决了我的问题,所以最后,我不确定为什么会发生这种情况,可能是因为我的 VS Code 在设置设置标志之前没有自动保存。
回答by Tomás
Solved it...
I haven't import all the libraries. So, I went to my root folder and excecute.npm install
thennpm start
解决了...我还没有导入所有的库。所以,我去了我的根文件夹并执行。npm install
然后npm start

