I have a react project that I am running using npm. When I do npm start, it launches on my default browser:- google chrome.
I would like to launch on firefox, safari and internet explorer for manual testing. I prefer don't making changes to package.json due to one time use.Any ideas on how to go about?
Specs
node -p process.arch: x64
node -p process.platform: darwin
npm info react version 16.4.0
macOS 10.13.4 (17E199)
Create an environment file .env
at the root of the project directory and add following entry
BROWSER=firefox
For a complete list of .env
file configuration, you can check here - https://facebook.github.io/create-react-app/docs/advanced-configuration
As I read on the script that runs when you run npm start, you may set an environment variable called BROWSER before running the npm start
For example (on linux):
(export BROWSER=firefox; npm start)
also, you may open the browsers after starting:
npm start &
firefox http://localhost:3000
safari http://localhost:3000
Save it to a something.sh and run this shell script. If you are on windows, you may do something similar on .bat script
you can install global node package called opn-cli then you can run the command. https://www.npmjs.com/package/opn-cli
Sample command:
npm start & opn http://localhost:4200 -- firefox & opn http://localhost:4200 -- chrome
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With