Jack The Baker
Jack The Baker

Reputation: 1903

Build Reactjs blank page and not generated other pages

I am newbie in reactjs, just create my first reactjs app, I want to make production version, and used this command:

npm run build

But in generated just a blank index.html file, why? Because I have many routes , how can I access other pages? and why index is blank?

{
  "name": "test",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "axios": "^0.19.0",
    "express": "latest",
    "nodemon": "^2.0.1",
    "react": "^16.9.0",
    "react-dom": "^16.9.0",
    "react-router-dom": "^5.0.1",
    "react-scripts": "3.1.0",
    "semantic-ui-css": "^2.4.1",
    "semantic-ui-react": "^0.88.1",
    "socket.io": "^2.3.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "universal-cookie": "^4.0.2"
  }
}

Upvotes: 2

Views: 3544

Answers (2)

Sandun Balasooriya
Sandun Balasooriya

Reputation: 34

Try

npm run build -- --profile

Upvotes: 0

Jatin Parmar
Jatin Parmar

Reputation: 2920

you need to add

"homepage": "http://mywebsite.com/relativepath",

in your package.json file if its hosted somewhre on server. or to run it locally you need to type following command

npm install -g serve
serve -s build

or you when using react-router you can set

EDIT

"homepage": "."

to work it locally

for more info read here

Upvotes: 2

Related Questions