node.js - 启动 REACT 前端时 npm 找不到 index.html
问题描述
当我尝试启动应用程序的前端时会出现问题。我在前端目录中使用以下命令执行此操作:npm start。它是一个 MERN 堆栈应用程序。我正在使用 git 进行版本控制。其他可以访问 git 的人可以在他们的机器上运行 npm start 而没有问题,所以我认为问题可能与 windows 文件或路径系统有关,但一直无法找到。
给出的错误:
Could not find a required file.
Name: index.html
Searched in: C:\Users\Liam\OneDrive\Desktop\COP4935\Project\DemocracyToken\public
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! frontend@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the frontend@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Liam\AppData\Roaming\npm-cache\_logs\2021-09-03T17_01_09_900Z-debug.log
当公共目录位于 DemocracyToken/frontend/ 时,npm 似乎正在尝试从项目根目录 (DemocracyToken) 访问公共目录
我努力了:
重新运行npm install,卸载并重新安装node,移动public文件夹的位置,移动index.html的位置。
这是我们应用程序的文件结构:
解决方案
推荐阅读
- reactjs - 如何在 useEffect 中测试带有异步状态更新的钩子?
- javascript - 我可以在模拟器上运行的科尔多瓦应用程序中显示控制台日志吗?
- android - 如果查询没有结果,Room 会返回什么
- spring-integration - 如何自行手动停止或启动@InboundChannelAdapter?
- typescript - 为什么 makeStyles 和 createStyles 必须分开(Material UI + TypeScript)?
- c++ - 比较字符串而不分配给变量的问题
- hazelcast - Hazelcast:门户序列化,具有相同类 ID 的不兼容类定义,版本 - 3.11.4
- python - python pandas - 将一列元组转换为字符串列
- android - 如何在 react-native 中动态设置公钥固定?
- linux - linux何时刷新tcp发送缓冲区?