找不到所需的文件。名称:index.html
我一直在研究这个 React 项目,几个月以来一直没有遇到这个错误。我没有对项目树中 index.html 文件的位置进行任何更改,这就是我无法解释此错误的原因。
我试过以下措施都没有成功:
- 更改公用文件夹的位置
- 更改公用文件夹内容的位置
- 更改 package-lock.json 的位置
- 更改 package.json 的位置
- npm 安装
- npm 安装反应脚本——保存
请查找终端中显示的错误:
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! [email protected] start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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.
回答如下:
index.html 已从 /public 目录中移动/删除
你的项目在public目录下有index.html文件吗?
如果没有,您可以在此处获得 Create React App 使用的那个
应该在
<your project root>/public/index.html
如果您使用 Git 进行版本控制,它将能够告诉您是否移动或删除了某些内容。
运行
git status
查看更改的文件