Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

node.js - Could not find a required file. Name: index.html

I have been working on this React project, since a few months without having come across this error. I haven't made any changes in the location of the index.html file in the project tree, which is why I can't explain this error.

I have tried the following measures without success:

  1. changing the location of public folder
  2. changing the location of contents of public folder
  3. changing the location of package-lock.json
  4. changing the location of package.json
  5. npm install
  6. npm install react-scripts --save

Please find the error displayed in the terminal:

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.
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

index.html has been moved/removed from the /public directory

Does your project have an index.html file in the public directory?

If not you can get the one that Create React App uses here

It should be in <your project root>/public/index.html


If you are using Git for version control it will be able to tell you if something was moved or removed.

Run git status to view changed files


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...