Skip to content
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

BROWSER=none not working - react-dev-utils package from npm not up-to-date with git? #1494

Closed
beac0n opened this issue Feb 7, 2017 · 9 comments

Comments

@beac0n
Copy link

beac0n commented Feb 7, 2017

Can you reproduce the problem with latest npm?

yes

Description

I wanted to use the BROWSER=none option, to prevent react-scripts from opening a new Browser.
Setting the env variable did not work at all.

after checking the openBrowser.js file in node_modules/react-dev-utils/ I realized, that it is different
from the openBrowser.js in the github repo:

/**

  • Copyright (c) 2015-present, Facebook, Inc.
  • All rights reserved.
  • This source code is licensed under the BSD-style license found in the
  • LICENSE file in the root directory of this source tree. An additional grant
  • of patent rights can be found in the PATENTS file in the same directory.
    */

var execSync = require('child_process').execSync;
var opn = require('opn');

function openBrowser(url) {
if (process.platform === 'darwin') {
try {
// Try our best to reuse existing tab
// on OS X Google Chrome with AppleScript
execSync('ps cax | grep "Google Chrome"');
execSync(
'osascript openChrome.applescript ' + url,
{cwd: __dirname, stdio: 'ignore'}
);
return true;
} catch (err) {
// Ignore errors.
}
}
// Fallback to opn
// (It will always open new tab)
try {
opn(url).catch(() => {}); // Prevent unhandledRejection error.
return true;
} catch (err) {
return false;
}
}

This file does not contain the check for BROWSER=none, but in
https://github.com/facebookincubator/create-react-app/blob/master/packages/react-dev-utils/openBrowser.js
it exists.

Expected behavior

using the env variable like BROWSER=none should prevent react-scripts from opening the browser

Actual behavior

When using BROWSER=none, the Browser still opens

Environment

Run these commands in the project folder and fill in their results:

  1. npm ls react-scripts (if you haven’t ejected):
    wine-page@0.1.0 /home/beac0n/dev/wine-page
    └── react-scripts@0.8.5

  2. node -v: v7.5.0

  3. npm -v: 4.1.2

  4. Operating system:
    Arch Linux

I could reproduce the issue when creating a new project with create-react-app 1.0.3.
I also ran npm cache clean, yarn cache clean - both commands with sudo and without.

I also downloaded the bundle manually from the npm registry:
https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-0.4.2.tgz

The openBrowser.js file still isn't the same as in the github repository.

@gaearon
Copy link
Contributor

gaearon commented Feb 7, 2017

The change was done in master but 0.9.0 has not been released yet. It will be released soon.

@gaearon gaearon closed this as completed Feb 7, 2017
@gaearon
Copy link
Contributor

gaearon commented Feb 11, 2017

0.9.0 is out now with support for this.

@beac0n
Copy link
Author

beac0n commented Feb 11, 2017

upgraded to 0.9.0, which resolved this issue :). Thanks a lot 👍

@lennerd
Copy link

lennerd commented Mar 17, 2017

Sorry, maybe I'm stupid but how were you able to update? I'm using react-dev-utils for our build setup and, I mean react-dev-utils is still on 0.5.2, no?

https://github.com/facebookincubator/create-react-app/blob/master/packages/react-dev-utils/package.json#L3

@Timer
Copy link
Contributor

Timer commented Mar 17, 2017

0.9.0 refers to the version of react-scripts, not react-dev-utils. You have the latest version.

@lennerd
Copy link

lennerd commented Mar 17, 2017

Okay, than the information in CHANGELOG are very confusing. 🙈

https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md#094-march-6-2017

It's saying that the version 0.9.4 contains some fixes published on the 9th of March. So now I guess 0.9.4 stands only for the create-react-app package version, right? That's were the confusion starts at least to me. It would help if the CHANGELOG also contains the version numbers of the child packages so it's easier to track them if you use them separately.

Than again I'm looking for changes from the PR #1546 which were merged on 15th of February.
This PR is adding the content-changed message to the client socket implementation to reload the page when files in the contentBase (/public) changed.

15th of February vs. 9th of March, but not part of the package? Looking into the webpackHotDevClient.js file from the latest release, the changes from #1546 are indead also not part of 0.9.4:

https://github.com/facebookincubator/create-react-app/blob/v0.9.4/packages/react-dev-utils/webpackHotDevClient.js#L247-L265

So apart from all this I'm also confused by the fact that older changes than the latest ones are not part of the latest version of the package. 🙈 😅

@lennerd
Copy link

lennerd commented Mar 17, 2017

Ah, now looking at #1546 a little closer I see that it changes are scheduled for 0.10.x by @gaearon. So you seem to cherry-pick changes from the current master?

Also, why is this scheduled for the next minor version? Worried about anything?

Apart from changes in a public folder, I would really love to reload the page in certain situation via webpackHotDevClient.

@gaearon
Copy link
Contributor

gaearon commented Mar 17, 2017

Changelog uses versions of react-scripts because that's the thing most people will upgrade. For other packages it's easiest to figure out what changes by looking at folder git history.

#1546 only works with Webpack 2 (afaik). So it's not released until we release a version of react-scripts compatible with Webpack 2.

Yea, we cherry-pick stable branch from master now but the next release will be done from master.

@lennerd
Copy link

lennerd commented Mar 17, 2017

Thank you for the explanations. I found and started to use the 0.6.0-beta release, so I can use the content reloading now.

@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants