我一直在研究这个 React 项目,几个月以来没有遇到这个错误。我没有对项目树中 index.html 文件的位置进行任何更改,这就是为什么我无法解释这个错误的原因。
我尝试了以下措施但没有成功:
- 更改公用文件夹的位置
- 更改公用文件夹内容的位置
- 更改 package-lock.json 的位置
- 更改 package.json 的位置
- npm 安装
- npm install react-scripts –save
请找到终端显示的错误:
Could not find a required file.
Name: index.html
Searched in: /Users/Sujay/Documents/Documents/Learn Web Development the Hard Way/lacapsule/project/Dark Sky Map Bitbucket/darkskymap_frontend/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! /Users/Sujay/.npm/_logs/2019-08-06T07_12_22_366Z-debug.log
Expected result : React project should launch without any issue.
Actual result: Error message in terminal mentioned above.
原文由 Sujay 发布,翻译遵循 CC BY-SA 4.0 许可协议
index.html 已从 /public 目录中移动/删除
您的项目在公共目录中有 index.html 文件吗?
如果没有,您可以在 此处获得 Create React App 使用 的那个
它应该在
<your project root>/public/index.html
如果您使用 Git 进行版本控制,它将能够告诉您是否移动或删除了某些内容。
运行
git status
查看更改的文件