You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Disabling opening of the browser in server start #873
It seemed like at an earlier version of create-react-app, running npm start would reconnect to the existing tab/process that it had been interacting with. With the current version, opening a new tab every time, having to close the new and refresh the old is a bit of an anti-pattern.
Reacted by Zeb Pykosz, Joel Hooks, Jisu Park, Harry Truong, Josh Hawkins, Anis Jonischkeit, Niyazi Hummatov, Chase Holdren, Florian Suess, strblr and 1 more
I'd really like to see this configurable — in my case it opens Safari (the default on the system) but not Chrome (which I use for dev).
How about we make it configurable via BROWSER env var (similar to EDITOR, right)? BROWSER=none will make it not open any browser but BROWSER=<path>|<name> will make it open correct browser.
Reacted by Saul Hardman, sirena-it, Harry Truong, Karel Klíma, Ville Immonen, Daniel Nguyen, Josh Hawkins, Ruslan Zaytsev, Keith D Commiskey, Jeff Gandt and 36 more
Any known workaround? I'm developing inside VBox Ubuntu on one monitor and have the app opened in Windows Chrome on another monitor. After a few hours of Ctrl+C, UP, Enter iterations the whole browser on VBox is flooded with new tabs :-)
+1 for choosing which browser to open. My default is firefox, but development is smoother on chrome.
Reacted by Karel Klíma, Dillon Hafer, Jesús Portillo, David Villamizar, TheWingMan, Florian Suess, Jordy, Jefferson Eagley, lebed2045 and Daniel Sánchez
Will #1032 always prevent the browser from opening? In which cases will the browser still auto open? I am failing at understanding exactly interactive and non-interactive real world examples.
This should be displayed when you 'npm start' so people don't have to search for the option. imho opening the browser was a gimmick feature and should be disabled by default.
Reacted by Mali McCalla, Kristofer Hamnell, Gabriel Théron, Tim Phillips, martin8877, Gitowiec, Nate Ryall, beezenees, David Roussov, Konstantin Melnikov and 1 more
This doesn't quite cut it for me since I need to run Chromium with options. Seems like opn requires parameters to be defined in an array. Maybe use process.env.BROWSER.split(' ') instead?
EDIT: Or, if that causes problems for Chrome on Mac (why is there a space in the name in the first place??), another env var such as BROWSER_PARAMS could be introduced.
Reacted by Alexander Kachkaev, jclc, Alper Ortac, Francis Batista, emilio, Chris Leong, Phi.Sanders, Joshua Sherer, Konstantin Melnikov and Daniel Sánchez
For those who want to build the "www" folder without auto-opening a browser, the simple answer is just npm run build:www
I wonder why all the convoluted routes... (scripts et-all) 😩
Thank you for the fix. It will be better to disable this option by default, because it's frustrating.
Instruction for those who will read this thread from the end:
create file .env in the same directory where your package.json lives
insert this line BROWSER=none to the file and save it
run nom start and web browser will not be opening anymore
Reacted by hglenski, Mikael Sundström, GlacJAY, Alex, Manish Sinha, Alex Devero, Erick Delfin, Aaron, Amritendu Bhattacharjee, matijamatija and 17 more
Reacted by Vuk Petrovic, Konstantin Melnikov and MichaelSwiatkiwsky
Reacted by Anton Danylchenko, Mikael Sundström, Alex Devero, Vuk Petrovic, Konstantin Melnikov, MichaelSwiatkiwsky and Liam
Reacted by Amritendu Bhattacharjee, Vuk Petrovic, Konstantin Melnikov, MichaelSwiatkiwsky and Andreas Ekström
Would really prefer for this feature to be disabled by default... but beggars can't be choosers.
In 99% of the situations, I already have the website running in an incognito window and opening a browser steals focus which is a bit obnoxious.
I'm on a Windows 10 machine and using the following command:
set BROWSER=NONE && npm start
The scripts work fine and everything compiles without a browser opening, but I get a windows error message saying "Windows cannot find 'NONE '. Make sure you typed the name correctly, and then try again."
This also happens when settings the environment variable through a .env file, and happens with both yarn and npm. Is this happening to anyone else?
EDIT: Apparently only when using the Command Prompt in a standalone window.
@Timer I'm curious about why the whitespace matters in this case? I'm also wondering if your solution will work cross-platform or if it's Windows-specific. Basically, I'm not sure if that's a good fix or if cross-env is the better choice.
Activity
sheerun commentedon Oct 8, 2016
For reason it's an option in custom-react-sctipts: https://github.com/kitze/create-react-app/tree/master/packages/react-scripts#others
tbillington commentedon Oct 8, 2016
It seemed like at an earlier version of create-react-app, running
npm startwould reconnect to the existing tab/process that it had been interacting with. With the current version, opening a new tab every time, having to close the new and refresh the old is a bit of an anti-pattern.glennreyes commentedon Oct 11, 2016
@tbillington A commit before #831 introduced this bug with the tabs, so this is fixed with the next release.
andreypopp commentedon Oct 18, 2016
I'd really like to see this configurable — in my case it opens Safari (the default on the system) but not Chrome (which I use for dev).
How about we make it configurable via
BROWSERenv var (similar toEDITOR, right)?BROWSER=nonewill make it not open any browser butBROWSER=<path>|<name>will make it open correct browser.gaearon commentedon Oct 18, 2016
@andreypopp 👍
kachkaev commentedon Nov 2, 2016
Any known workaround? I'm developing inside VBox Ubuntu on one monitor and have the app opened in Windows Chrome on another monitor. After a few hours of
Ctrl+C,UP,Enteriterations the whole browser on VBox is flooded with new tabs :-)gaearon commentedon Nov 2, 2016
No, there is currently no workaround except submitting a PR that @andreypopp suggested above.
sheerun commentedon Nov 10, 2016
I've submitted a fix that disables opening browser in non-interactive terminal #1032
glennreyes commentedon Nov 10, 2016
@gaearon There's a fork by @kitze that does very similar things like suggested from @andreypopp. Would you accept a PR for that?
kitze commentedon Nov 11, 2016
@glennreyes yup, but in my fork you can just set
OPEN_BROWSER=falsein .env, you cannot specify the browser.GAumala commentedon Nov 12, 2016
+1 for choosing which browser to open. My default is firefox, but development is smoother on chrome.
gaearon commentedon Nov 24, 2016
Is this fixed by #1032?
How can people opt into this mode? @sheerun
vvo commentedon Nov 24, 2016
Will #1032 always prevent the browser from opening? In which cases will the browser still auto open? I am failing at understanding exactly interactive and non-interactive real world examples.
22 remaining items
Tectract commentedon Apr 28, 2017
This should be displayed when you 'npm start' so people don't have to search for the option. imho opening the browser was a gimmick feature and should be disabled by default.
Configure which browser to open in npm start (react#873) (react#1148)
jclc commentedon Oct 5, 2017
This doesn't quite cut it for me since I need to run Chromium with options. Seems like opn requires parameters to be defined in an array. Maybe use process.env.BROWSER.split(' ') instead?
EDIT: Or, if that causes problems for Chrome on Mac (why is there a space in the name in the first place??), another env var such as BROWSER_PARAMS could be introduced.
GAumala commentedon Oct 5, 2017
@jclc if you want to run Chromium with options you can pass a JS script with
BROWSER. For example:Then you start the dev server like this:
jclc commentedon Oct 5, 2017
I see, thank you
chiemekailo commentedon Oct 14, 2017
For those who want to build the "www" folder without auto-opening a browser, the simple answer is just
npm run build:wwwI wonder why all the convoluted routes... (scripts et-all) 😩
1st commentedon Mar 14, 2018
Thank you for the fix. It will be better to disable this option by default, because it's frustrating.
Instruction for those who will read this thread from the end:
.envin the same directory where yourpackage.jsonlivesBROWSER=noneto the file and save itnom startand web browser will not be opening anymoreRemove default browser opening on server start
ChuckkNorris commentedon Mar 27, 2018
Would really prefer for this feature to be disabled by default... but beggars can't be choosers.
In 99% of the situations, I already have the website running in an incognito window and opening a browser steals focus which is a bit obnoxious.
Aias commentedon Jun 12, 2018
I'm on a Windows 10 machine and using the following command:
set BROWSER=NONE && npm startThe scripts work fine and everything compiles without a browser opening, but I get a windows error message saying "Windows cannot find 'NONE '. Make sure you typed the name correctly, and then try again."
This also happens when settings the environment variable through a .env file, and happens with both yarn and npm. Is this happening to anyone else?
EDIT: Apparently only when using the Command Prompt in a standalone window.
Timer commentedon Jun 13, 2018
set BROWSER=none&&npm startshould work fine.Note, the lack of whitespace around
&&is intentional.reed665 commentedon Jun 16, 2018
You can make use of
cross-envas an optionmzedeler commentedon Nov 8, 2018
I'm just waiting for someone to publish a browser named
none:-Dborrascador commentedon Dec 13, 2018
@Timer I'm curious about why the whitespace matters in this case? I'm also wondering if your solution will work cross-platform or if it's Windows-specific. Basically, I'm not sure if that's a good fix or if cross-env is the better choice.