6

I have created react application using create-react-app when I start "npm start" it is running using localhost:3000 in browser which is fine. But, when I click index.html from project folder it is showing blank page. Can you suggest me solutions on how to run react application using index.html file

2 Answers 2

8

Add "homepage": ".", to the top of your package.json file. Then build with yarn build or npm build. Go to build/ folder and double click on index.html. enter image description here enter image description here

EDIT:

Opening the app via index.html needs "homepage": "." in package.json because without it Webpack tries to load the static files from the root the file system rather than build directory. Reference

Sign up to request clarification or add additional context in comments.

2 Comments

can you please share the details about "homepage": ".",
@DeepKakkar I added an explanation in the answer. Thank you for your comment.
0

You can run npm run build, then go to the “build” folder where a working index.html will be located. The index.html in the project folder isn’t built for production/standalone use.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.