3

i have a problem. When i build my React project using npm run build && serve-s build the project build running a blank page.

I search on Google this problem and the community fix using "homepage": "." in the package.json, then i tried set this flag, but nothing. I tried too using "homepage": "mysite.com/site/app/build" (this is path to my project).

And my package.json includes "homepage": "."

I'm using react-router-dom for routes managment and i tried change the BrwoserRouter to HashRouter and add basename="/" to BrwoserRouter and nothing.

Someone help me?

2 Answers2

1

homepage is not the path to the project. It is the home page of your website or you can say the address where it will be visible, so your homepage should be something like-

homepage: "https://yourdomain.com"

And pls give more detail so we can help

1

I solved this problem by doing two things:

  1. In my package.json I included: "homepage": "."

  2. In my src/index.js file, where I imported BrwoserRouter, I removed the exact prop:

    Before: <Route exact={true} path="/" component={App} />

    After: <Route path="/" component={App} />

It worked for me!