简体   繁体   中英

reactjs build with routes blank page

I have reactjs app, it's my first time that want to deploy/build my app, I know it's simply can do:

npm run build

I used this on a very simple react app before, it work fine, but now I want to deploy my react app that use react-router-dom , after I run npm run build , index.html is blank, it's okay maybe, because I don't have a route for home page, for example one of my page in develop mode:

    <Switch>
...
        <Route exact path='/User/Login' component={Login}></Route>
...
    </Switch>

/User/Login

How can I access this page after deploy? I am super newbie to reactjs, I don't know how to handle this, many search, but can't find anything useful in my native language.


Packages.json

  "name": "sample",
  "homepage": "http://example.com/react/",
  "version": "0.1.0",
  "private": true,

React App needs a node server to be hosted. If you want to host on linux/Ubuntu server then you will need to install node.js from NVM Full Tutorial or you can go for Gatsby to create static react apps.

You can host your react app on AWS / Heroku etc.

If you are deploying react build for learning purpose only then you can use static server locally: npm i serve -g
serve -s build

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM