Skip to content

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

Closed
@beac0n

Description

@beac0n

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions