首页 > 解决方案 > 启动 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的位置。

这是我们应用程序的文件结构:

vs项目目录截图

标签: node.jsreactjsnpmmern

解决方案


推荐阅读