Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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! [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.
like image 300
Sujay Avatar asked Aug 06 '19 07:08

Sujay


People also ask

What is in index HTML?

Default Homepage The index. html page is the most common name used for the default page shown on a website if no other page is specified when a visitor requests the site. In other words, index. html is the name used for the homepage of the website.

What is public folder in React JS?

The public folder contains static files such as index. html, javascript library files, images, and other assets, etc. which you don't want to be processed by webpack. Files in this folder are copied and pasted as they are directly into the build folder.


3 Answers

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

like image 182
Jonathan Irwin Avatar answered Sep 20 '22 07:09

Jonathan Irwin


I had the exact same problem. Both my package-lock and package.json were outside of the root folder. Once I moved them into the root folder it started up just fine.

like image 45
Peter May Avatar answered Sep 22 '22 07:09

Peter May


Your public folder might be missing, just create another app using create-react-app and copy paste the public folder in this directory

like image 38
Ajay Tom George Avatar answered Sep 24 '22 07:09

Ajay Tom George