React blank page after running npm run build because of react-router-dom

Asked
Active3 hr before
Viewed126 times

8 Answers

routerreact
90%

This problem was introduced after I implemented the router. Previously the result of both npm start and npm run build were the same.,Please be sure to answer the question. Provide details and share your research!, What are the main open problems in the theory of amenability of groups?

You should serve the build folder for example like

npx serve - s build
88%

The next time you get a white screen after deploying a React app, remember the steps you’ve learned today:,Now that we told your app it’s base URL, run npm run build again and copy the app to your web space to find your app up and running., How to fix the Whitescreen After a Static Deployment with create-react-app

If you check the DOM of your index.html, you’ll see, that the JavaScript bundle’s links are absolute URLs – from the root of your application:

<script src="/static/js/1.3aec9dfa.chunk.js"></script>
<script src="/static/js/main.72f93e60.chunk.js"></script>
72%

Useful package, i already follow you instruction. But i got blank page,All users using Github Page to deploy their react-router based app should read this issue!,Here my package.json:

node - v
v9 .7 .1

npm - v
6.0 .1

create - react - app--version
1.5 .2
load more v
65%

I build a SPA with React and React Router. I'm also using https://github.com/facebookincubator/create-react-app as it's a really simple application. When I'm developing using webpack I can see the page fine. However, after I build for production using npm run build from create-react-app I get HTML file and css and js normally. I uploaded everything to S3 but when I go to the page I only get blank page,And this is the template creawte-react-app use and it's working fine on development.,If you have a route for index.html, that will be matched when the page loads and things might appear to work. If your app has a <Link> to an /other route, you could even click on it and the URL would be changed to example.com/other.

And this is what I'm seeing

<!-- react-empty: 1 -->
load more v
75%

To create a build folder, just execute the npm run build or yarn build command from the command line from your project folder.,The index.html file contains our entire React app code. It gets generated inside the build folder when the yarn build command is executed by Netlify while deploying the app.,Once the build folder is created, you just need to drop the folder in the drop area under the sites menu, as shown below:

Create a new file with the name _redirects inside the public folder of our project and add the following contents inside it:

/* /index.html 200
40%

I have created a website using create-react-app however when I try to run it using yarn build all I get is a blank white page and this error in the console:,Built on Forem — the open source software that powers DEV and other inclusive communities., We're a place where coders share, stay up-to-date and grow their careers.

  Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
  work correctly both with client-side routing and a non-root public URL.
  Learn how to configure a non-root public URL by running `npm run build`.
  -->
  <title>StatHero</title>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
load more v
22%

It is an existing github repo build on react. Blank white screen when deploying a react app Support Make sure your assets are in the correct publish directory after the build :smile: You site build is creating a reference to a subdirectory in your javascript URLs. do you think “redirects rule” can solve my problem ?,Get code examples like "how to fix the white screen after a static deployment with create-react-app" instantly right from your google search results with the,How to fix the white screen after a static deployment with create-react-app occurs when react is rendering, a white screen will show in static build and a stack

Pretag
 Pretag team - issue, fix, solve, resolve
60%

In this step, you’ll create a new application using the npm package manager to run a remote script. The script will copy the necessary files into a new directory and install all dependencies.,You will also see a list of npm commands that will allow you to run, build, start, and test your application. You’ll explore these more in the next section.,The last file is a package.json. This contains metadata about your project, such as the title, version number, and dependencies. It also contains scripts that you can use to run your project.

Pretag
 Pretag team - issue, fix, solve, resolve

Other "router-react" queries related to "React blank page after running npm run build because of react-router-dom"