-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disabling opening of the browser in server start #873
Comments
For reason it's an option in custom-react-sctipts: https://github.com/kitze/create-react-app/tree/master/packages/react-scripts#others |
It seemed like at an earlier version of create-react-app, running |
@tbillington A commit before #831 introduced this bug with the tabs, so this is fixed with the next release. |
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 |
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 |
No, there is currently no workaround except submitting a PR that @andreypopp suggested above. |
I've submitted a fix that disables opening browser in non-interactive terminal #1032 |
@gaearon There's a fork by @kitze that does very similar things like suggested from @andreypopp. Would you accept a PR for that? |
@glennreyes yup, but in my fork you can just set |
+1 for choosing which browser to open. My default is firefox, but development is smoother on chrome. |
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. |
Basically if won't show up if you do |
As for my usecase (and maybe many others?) what I would need is indeed a flag as in the linked fork in this topic. Much like what browsersync provides https://www.browsersync.io/docs/command-line#start (--no-open) flag |
I think the |
Use a 'BROWSER' environment variable with npm start to specify which browser to open. if the value of 'BROWSER' is not valid executable file, don't open any browser.
I have prepared a PR with the suggested approach, the |
@GAumala |
@shrynx I'm afraid it is not that simple. In my Arch Linux laptop google chrome is |
@GAumala Ahh , really ? that's kind of the thing i am pointing at. OS specific names are different, so it would be much easier for the user if they had to just specify chrome, ie or firefox and rest be handled by CRA. |
Using an environment variable to override a default executable is common, and I'd be more confused if it tried to do something fancy.
An apt example is EDITOR. All it does is specify what command to execute to open an editor. It lets the system handle path resolution. `EDITOR=vim` can execute `/usr/bin/vim` or `/usr/local/bin/vim` or `~/bin/vim` or whatever - CRA has no business trying to figure that out.
edit: clarification
… On Dec 4, 2016, at 7:47 PM, Shriyans ***@***.***> wrote:
@GAumala Ahh , really ? that's kind of the thing i am pointing at. OS specific names are different, so it would be much easier for the user if they had to just specify chrome, ie or firefox and rest be handled by CRA.
I'll try if it works with arch and try to fix it.
Also if CRA could cover most common use cases (windows, mac and ubuntu) it should be good enough, with documentation for special cases like arch et al.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
This was fixed by #1148 with an It will take a few weeks until 0.9.0 is out with this, but I’ll close the issue since it’s not actionable now. Thanks to everyone for the discussion and suggestions. |
To clarify, the name of the new env variable is |
Oh right. :-) |
Should the new environment variable be documented in the user guide? |
Ideally I’d like a new section documenting all env variables we read. |
Yeah I was thinking about that too. I only knew about |
…#1148) Use a 'BROWSER' environment variable with npm start to specify which browser to open. if the value of 'BROWSER' is not valid executable file, don't open any browser.
FYI support for |
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. |
…#1148) Use a 'BROWSER' environment variable with npm start to specify which browser to open. if the value of 'BROWSER' is not valid executable file, don't open any browser.
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. |
@jclc if you want to run Chromium with options you can pass a JS script with // openChromium.js
const opn = require('opn');
opn('http://localhost:3000', {app: ['chromium', '--option1', '--option2']}); Then you start the dev server like this: BROWSER=openChromium.js npm start |
I see, thank you |
For those who want to build the "www" folder without auto-opening a browser, the simple answer is just |
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:
|
Would really prefer for this feature to be disabled by default... but beggars can't be choosers. |
I'm on a Windows 10 machine and using the following command:
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. |
Note, the lack of whitespace around |
You can make use of cross-env BROWSER=none npm start |
I'm just waiting for someone to publish a browser named |
@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. |
While "cool":
Could we disable auto-opening of browser window? Or at least in non-interactive mode?
The text was updated successfully, but these errors were encountered: