create-react-app: How do I “npm start” with a specific browser?

后端 未结 11 1979
一个人的身影
一个人的身影 2021-01-31 07:11

npm start

starts the react server on the default browser, which is Firefox for me. I like Firefox for browsing but prefer Chrome in web deve

11条回答
  •  故里飘歌
    2021-01-31 07:57

    As you have mentioned that you are using create-react-app for creating react app and you want chrome to open on hitting npm start. Set BROWSER variable in package.json present in your project in the following manner:

    Replace:

    "start": "react-scripts start"
    

    With:

    • Linux:
      "start": "BROWSER='google-chrome-stable' react-scripts start"
      
    • Windows:
      "start": "BROWSER='chrome' react-scripts start"
      
    • OS X:
      "start": "BROWSER='google chrome' react-scripts start"
      

提交回复
热议问题