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. 

5 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

4

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

1

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.

In my case, I have accidentally deleted the public directory so it couldn't find the index.html file

Leaving this here in case you had the same issue as me and your index.html file is exactly where you want it and where you told app engine.

Add package.json to your .glcoudignore file at the root level of your project.

I had a tonne of issues with this and my exact setup had previously worked so I'm not sure what the issue was.

I'm using create-react-app (CRA) and my app.yaml file looks like this:

runtime: nodejs16 handlers: # Serve all static files with url ending with a file extension - url: /(.*\..+)$ static_files: build/\1 upload: build/(.*\..+)$ # Catch all handler to index.html - url: /.* static_files: build/index.html upload: build/index.html 

With CRA npm run build will build the project to a /build directory and place index.html inside it.

That app.yaml file should point at it and everything should be grand.

The issue though was that app engine will try and run npm start if it's in your package.json file. Changing the script name to dev instead of start still didn't work when I tried to deploy and instead I just had to include package.json in my .gcloudignore file.

This is a pain because it just means that I have to build the app before deploying always. But this is how I was able to get this to work after spending hours looking into the issue.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.