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

后端 未结 11 1978
一个人的身影
一个人的身影 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 08:12

    Using above technique, you may end up with error 'BROWSER' is not recognized as an internal or external command, operable program or batch file.

    To over come this Do an npm install of cross-env in your cloned repo: npm install --save cross-env

    Try to use this command in the package.json file

    "start": "cross-env BROWSER=chrome react-scripts start"

    BROWSER is an environment variable, and you can use the cross-env package to properly handle it.

提交回复
热议问题