create-react-app npm run build command

前端 未结 9 699
春和景丽
春和景丽 2020-12-15 18:03

I have a built a small React application with create-react-app, and it runs fine from the local server after running npm start. OK so far.

9条回答
  •  醉梦人生
    2020-12-15 18:09

    you can't run the production build by clicking on index.html, you have to modify your script like bellow.

    "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "deploy": "serve -s build"
      }
    

    after running npm run-script build, run npm run-script deploy, you will get some thing like this, this is where you can load your production build.

    npm install -g serve before run npm run-script deploy.

提交回复
热议问题