React组件文件夹未检测到
我在React中遇到以下错误。这似乎与这个相似。
我尝试将.jsx文件重命名为.js文件,并重新检查了上述问题中给出的导入路径,但它们仍然给我同样的错误。这是我的错误的图像。 vs代码错误和文件夹结构
我的代码app.js文件如下。
import './App.css';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import {ListSalaryComponent,CreateSalaryComponent,UpdateSalaryComponent,ListItemComponent,CreateItem,UpdateItemComponent,CreateMachineComponent,ListMachineComponent,UpdateMachineComponent} from './components';
import LogIn from './pages/LogIn';
import QuotationRequest from './pages/QuotationRequest';
import QuotationProcessIntro from './pages/QuotationProcessIntro';
function App() {
return (
<>
<Router>
<Switch>
<Route exact path='/viewInvoice/:invoice_id'>
<ViewInvoiceComponent />
</Route>
<Route path="/salaries" >
<ListSalaryComponent/>
</Route>
<Route path="/add-salary">
<CreateSalaryComponent/>
</Route>
<Route path="/update-salary/:id">
<UpdateSalaryComponent/>
</Route>
<Route path="/listitems"><ListItemComponent/></Route>
<Route path="/items" ><ListItemComponent /></Route>
<Route path="/add-item"><CreateItem/></Route>
<Route path="/edit-item/:item_code"> <UpdateItemComponent/></Route>
<Route path="/machine-list" ><ListMachineComponent/></Route>
<Route path="/machines"> <ListMachineComponent/></Route>
<Route path="/add-Machine"> <CreateMachineComponent/></Route>
<Route path="/update-Machine/:id"> <UpdateMachineComponent/></Route>
</Switch>
</Router>
<QuotationRequest></QuotationRequest>
</>
);
}
export default App;
这是我收到的完整错误消息。
错误中的错误/src/app.js 6:0-220 找不到的模块:错误:无法解决'./components/'in'D:\ sliit \ y2S2 \ itp \ itp \ iTP \ project \ project \ project code \ itp_project_group_b1-wd_b01_itp_g16 \ devagition resolve'./components/'in'D:\ sliit \ y2s2 \ itp \ itp \ project \ project code \ itp_project_group_b1-wd_b01_itp_g16 \ development \ itp-frontend \ itp-frontend \ src' 解析请求是目录 使用说明文件:D:\ SLIIT \ Y2S2 \ itp \ project \ Project code \ itp_project_group_b1-wd_b01_itp_g16 \ development \ itp-frontend \ package.json(eval path:./ src) 字段“浏览器”不包含有效的别名配置 使用说明文件:D:\ SLIIT \ Y2S2 \ ITP \ Project \ Project Code \ ITP_PROJEMT_GROUP_B1-WD_B01_ITP_G16 \ development \ itp-frontend \ package.json(eval path:./src/components) 作为目录 现有目录d:\ sliit \ y2s2 \ itp \ project \ project code \ itp_project_group_b1-wd_b01_itp_g16 \ development \ itp-frontend \ src \ components 使用说明文件:D:\ SLIIT \ Y2S2 \ ITP \ Project \ Project Code \ ITP_PROJEMT_GROUP_B1-WD_B01_ITP_G16 \ development \ itp-frontend \ package.json(eval path:./src/components) 使用路径:d:\ sliit \ y2s2 \ itp \ project \ project code \ itp_project_group_b1-wd_b01_itp_g16 \ development \ itp-frontend \ src \ components \ components \ Index 使用描述文件:D:\ SLIIT \ Y2S2 \ itp \ Project \ Project \ Project Code \ itp_project_group_b1-wd_b01_itp_g16 \ development \ itp-frontend \ itp-frontend \ package.json 没有扩展 字段“浏览器”不包含有效的别名配置 d:\ sliit \ y2s2 \ itp \ project \ project code \ itp_proipt_group_b1-wd_b01_itp_g16 \ development \ itp-frontend \ src \ components \ Index不存在 .web.mjs 字段“浏览器”不包含有效的别名配置 d:\ sliit \ y2s2 \ itp \ project \ project code \ itp_proipt_group_b1-wd_b01_itp_g16 \ development \ itp-frontend \ src \ components \ components \ index.web.mjs不存在 .mjs 字段“浏览器”不包含有效的别名配置 d:\ sliit \ y2s2 \ itp \ project \ project code \ itp_proipt_group_b1-wd_b01_itp_g16 \ development \ itp-frontend \ src \ components \ index.mjs不存在 .web.js 字段“浏览器”不包含有效的别名配置 d:\ sliit \ y2s2 \ itp \ project \ project code \ itp_proipt_group_b1-wd_b01_itp_g16 \ development \ itp-frontend \ src \ components \ components \ index.web.js不存在 .js 字段“浏览器”不包含有效的别名配置 d:\ sliit \ y2s2 \ itp \ project \ project code \ itp_project_group_b1-wd_b01_itp_g16 \ development \ itp-frontend \ src \ components \ components \ index.js不存在 .json 字段“浏览器”不包含有效的别名配置 d:\ sliit \ y2s2 \ itp \ project \ project code \ itp_proipt_group_b1-wd_b01_itp_g16 \ development \ itp-frontend \ src \ components \ index.json不存在 .web.jsx 字段“浏览器”不包含有效的别名配置 d:\ sliit \ y2s2 \ itp \ project \ project code \ itp_proipt_group_b1-wd_b01_itp_g16 \ development \ itp-frontend \ src \ components \ components \ index.web.jsx不存在 .jsx 字段“浏览器”不包含有效的别名配置 d:\ sliit \ y2s2 \ itp \ project \ project code \ itp_proipt_group_b1-wd_b01_itp_g16 \ development \ itp-frontend \ src \ components \ components \ index.jsx不存在 @ ./src/index.js 8:0-24 12:33-36
WebPack 5.70.0编译了1个错误和1个警告,在676 ms中
I'm getting the following error in react. It appears to be bit simillar to this one.
Can't resolve module (not found) in React.js
I tried the renaming .jsx files to .js files and rechecked the import path as given in the above question, but they still give me the same error. Here is an image of what my error looks like.vs code error and folder structure
Code of my App.js file is given below.
import './App.css';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import {ListSalaryComponent,CreateSalaryComponent,UpdateSalaryComponent,ListItemComponent,CreateItem,UpdateItemComponent,CreateMachineComponent,ListMachineComponent,UpdateMachineComponent} from './components';
import LogIn from './pages/LogIn';
import QuotationRequest from './pages/QuotationRequest';
import QuotationProcessIntro from './pages/QuotationProcessIntro';
function App() {
return (
<>
<Router>
<Switch>
<Route exact path='/viewInvoice/:invoice_id'>
<ViewInvoiceComponent />
</Route>
<Route path="/salaries" >
<ListSalaryComponent/>
</Route>
<Route path="/add-salary">
<CreateSalaryComponent/>
</Route>
<Route path="/update-salary/:id">
<UpdateSalaryComponent/>
</Route>
<Route path="/listitems"><ListItemComponent/></Route>
<Route path="/items" ><ListItemComponent /></Route>
<Route path="/add-item"><CreateItem/></Route>
<Route path="/edit-item/:item_code"> <UpdateItemComponent/></Route>
<Route path="/machine-list" ><ListMachineComponent/></Route>
<Route path="/machines"> <ListMachineComponent/></Route>
<Route path="/add-Machine"> <CreateMachineComponent/></Route>
<Route path="/update-Machine/:id"> <UpdateMachineComponent/></Route>
</Switch>
</Router>
<QuotationRequest></QuotationRequest>
</>
);
}
export default App;
Here is the complete error message I get.
ERROR in ./src/App.js 6:0-220
Module not found: Error: Can't resolve './components/' in 'D:\SLIIT\Y2S2\ITP\Project\Project Code\itp_project_group_b1-wd_b01_itp_g16\Development\itp-frontend\src'
resolve './components/' in 'D:\SLIIT\Y2S2\ITP\Project\Project Code\itp_project_group_b1-wd_b01_itp_g16\Development\itp-frontend\src'
Parsed request is a directory
using description file: D:\SLIIT\Y2S2\ITP\Project\Project Code\itp_project_group_b1-wd_b01_itp_g16\Development\itp-frontend\package.json (relative path: ./src)
Field 'browser' doesn't contain a valid alias configuration
using description file: D:\SLIIT\Y2S2\ITP\Project\Project Code\itp_project_group_b1-wd_b01_itp_g16\Development\itp-frontend\package.json (relative path: ./src/components)
as directory
existing directory D:\SLIIT\Y2S2\ITP\Project\Project Code\itp_project_group_b1-wd_b01_itp_g16\Development\itp-frontend\src\components
using description file: D:\SLIIT\Y2S2\ITP\Project\Project Code\itp_project_group_b1-wd_b01_itp_g16\Development\itp-frontend\package.json (relative path: ./src/components)
using path: D:\SLIIT\Y2S2\ITP\Project\Project Code\itp_project_group_b1-wd_b01_itp_g16\Development\itp-frontend\src\components\index
using description file: D:\SLIIT\Y2S2\ITP\Project\Project Code\itp_project_group_b1-wd_b01_itp_g16\Development\itp-frontend\package.json (relative path: ./src/components/index)
no extension
Field 'browser' doesn't contain a valid alias configuration
D:\SLIIT\Y2S2\ITP\Project\Project Code\itp_project_group_b1-wd_b01_itp_g16\Development\itp-frontend\src\components\index doesn't exist
.web.mjs
Field 'browser' doesn't contain a valid alias configuration
D:\SLIIT\Y2S2\ITP\Project\Project Code\itp_project_group_b1-wd_b01_itp_g16\Development\itp-frontend\src\components\index.web.mjs doesn't exist
.mjs
Field 'browser' doesn't contain a valid alias configuration
D:\SLIIT\Y2S2\ITP\Project\Project Code\itp_project_group_b1-wd_b01_itp_g16\Development\itp-frontend\src\components\index.mjs doesn't exist
.web.js
Field 'browser' doesn't contain a valid alias configuration
D:\SLIIT\Y2S2\ITP\Project\Project Code\itp_project_group_b1-wd_b01_itp_g16\Development\itp-frontend\src\components\index.web.js doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
D:\SLIIT\Y2S2\ITP\Project\Project Code\itp_project_group_b1-wd_b01_itp_g16\Development\itp-frontend\src\components\index.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
D:\SLIIT\Y2S2\ITP\Project\Project Code\itp_project_group_b1-wd_b01_itp_g16\Development\itp-frontend\src\components\index.json doesn't exist
.web.jsx
Field 'browser' doesn't contain a valid alias configuration
D:\SLIIT\Y2S2\ITP\Project\Project Code\itp_project_group_b1-wd_b01_itp_g16\Development\itp-frontend\src\components\index.web.jsx doesn't exist
.jsx
Field 'browser' doesn't contain a valid alias configuration
D:\SLIIT\Y2S2\ITP\Project\Project Code\itp_project_group_b1-wd_b01_itp_g16\Development\itp-frontend\src\components\index.jsx doesn't exist
@ ./src/index.js 8:0-24 12:33-36
webpack 5.70.0 compiled with 1 error and 1 warning in 676 ms
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论