简体   繁体   English

当我导入 BrowserRouter 时,在 reactJS 中遇到此错误“错误:ENOENT:没有此类文件或目录,stat '/initrd.img'”

[英]Encountering this error "Error: ENOENT: no such file or directory, stat '/initrd.img'" in reactJS when i import BrowserRouter

Multiple people ( like asked here ) have asked the same question but I couldn't resolve my problem as almost all the solutions asked me to check for mistakes while importing but I am sure I went through all of them but couldn't find anyone that made sense to me.多个人( 就像在这里问过的)问过同样的问题,但我无法解决我的问题,因为几乎所有的解决方案都要求我在导入时检查错误,但我确信我经历了所有这些但找不到任何人对我来说很有意义。 My code used to be much bigger but as someone mentioned in the solution to the post I have tagged previously, I created a new app using CRA and imported things one by one only to realize that this error started appearing as soon as I imported the routing method as mentioned in my code.我的代码过去要大得多,但是正如我之前标记的帖子的解决方案中提到的那样,我使用 CRA 创建了一个新应用程序并一个一个地导入了一些东西,只是意识到这个错误在我导入路由后就开始出现我的代码中提到的方法。
I am aware that this error is pointing to the broken symlinks in my system as mentioned in some other posts(also pointed to another symlink when I previously ran my code) but I am trying to find a way to resolve this without damaging my system by deleting symlinks.我知道这个错误指向我系统中损坏的符号链接,正如其他一些帖子中提到的那样(当我之前运行我的代码时也指向另一个符号链接),但我试图找到一种方法来解决这个问题而不会损坏我的系统删除符号链接。 After using CRA to make a new app I tried to run this code which worked fine until I imported Router.在使用 CRA 制作一个新应用程序后,我尝试运行这段代码,该代码在我导入 Router 之前运行良好。

edit: As soon as I removed routing from my initial project (which had multiple components ) it got fixed.编辑:一旦我从我的初始项目(有多个组件)中删除路由,它就得到了修复。 I need to figure out a way to route this now.我现在需要想办法解决这个问题。

My index.js CODE:我的 index.js 代码:

import React from 'react'; 
import {render} from 'react-dom'; 
import App from './App';  
import {BrowserRouter as Router} from'react-router-dom';
render(    
    <Router>
         <App />   
    </Router>,  
     document.getElementById('root') );
     

My App.js CODE:我的 App.js 代码:

import React from "react";

function App()
{
  return(
     <h1>  hello world  </h1> 
  )
}

export default App;
 

PS: Thank you for reading my post, please post your solutions or links that might help. PS:感谢您阅读我的帖子,请发布您的解决方案或可能有帮助的链接。

You are probably missing @material-ui/icons您可能缺少@material-ui/icons

Try to install it尝试安装它

npm install @material-ui/icons

In my case an import statement was missing a file.在我的情况下, import语句缺少文件。 Check your import statements.检查您的导入语句。 It actually shows what's missing for a second on the Compiling... screen after npm start它实际上在npm start后的Compiling...屏幕上显示了缺少的内容

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:ENOENT:没有这样的文件或目录,统计 - Error: ENOENT: no such file or directory, stat 错误:ENOENT:没有这样的文件或目录,stat ... .steampath - Error: ENOENT: no such file or directory, stat ... .steampath UnhandledPromiseRejectionWarning:错误:ENOENT:没有这样的文件或目录,stat&#39;/assets/level.png&#39; - UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, stat '/assets/level.png' 错误:Enoent:没有这样的文件或目录,状态为&#39;D:\\ awesome-testindex.html&#39; - Error :Enoent :no such file or directory ,stat 'D:\awesome-testindex.html' 错误:ENOENT:没有这样的文件或目录,stat Laravel mix bug - Error: ENOENT: no such file or directory, stat Laravel mix bug 错误:ENOENT:没有这样的文件或目录,stat '/home/arpit/.steampath' - Error: ENOENT: no such file or directory, stat '/home/arpit/.steampath' 错误:ENOENT:没有这样的文件或目录 - Error: ENOENT: no such file or directory 错误:ENOENT:没有这样的文件或目录,错误时统计“/public/main.html”(本机) - Error: ENOENT: no such file or directory, stat '/public/main.html' at Error (native) webpack + express + angular 4错误“错误:ENOENT:没有这样的文件或目录,统计信息&#39;C:\\ public \\ index.html&#39; - webpack + express + angular 4 error "Error: ENOENT: no such file or directory, stat 'C:\public\index.html' 服务器给出错误:ENOENT:没有这样的文件或目录,stat &#39;F:\\web development\\calculator\\index.html&#39; - server is giving Error: ENOENT: no such file or directory, stat 'F:\web development\calculator \index.html '
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM