2

I'm currently learning React and have just switched to a windows environment using wsl2 and remote vscode for development.

When running npm start for starting the dev server, vscode opens a browser.sh window with the following info:


#!/usr/bin/env sh
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
ROOT=$(dirname "$(dirname "$(dirname "$0")")")

APP_NAME="code"
VERSION="1.52.1"
COMMIT="ea3859d4ba2f3e577a159bc91e3074c5d85c0523"
EXEC_NAME="code"
CLI_SCRIPT="$ROOT/out/vs/server/cli.js"
"$ROOT/node" "$CLI_SCRIPT" "$APP_NAME" "$VERSION" "$COMMIT" "$EXEC_NAME" "--openExternal" "$@"

The server does compile successfully and I can view the page in my browser, but I have to manually enter the url to view it.

I'm not sure why the browser.sh window is opening, as well as if I'm supposed to make changes to this file. I wondered if this is opening as the dev-server is unable to access the browser window to open the react page?

When I've downloaded older projects not using the most modern React version and installed the dependencies, this same experience of having a browser.sh window does not open, as well the dev-server was able to open a browser window for me without me having to manually type in the url.

If someone could give me some guidance on what the issue is here, and whether I need to make a change to this browser.sh file to allow for the dev-server to automatically open the page that would be very much appreciated. See below my package.json file:

{
  "name": "off-plateform",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.11.9",
    "@testing-library/react": "^11.2.3",
    "@testing-library/user-event": "^12.6.2",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-scripts": "4.0.1",
    "web-vitals": "^0.2.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Thank you in advance.

Andrew Reynolds
  • 101
  • 1
  • 1
  • 3
  • Can you include the contents of your `package.json` file ? – turbopasi Jan 25 '21 at 22:29
  • 1
    Hi Pascal, apologies for not including it before. I've added it to my original comment. – Andrew Reynolds Jan 25 '21 at 23:22
  • Another question about this same problem provides a bit more info (new in version 1.52, release notes, env variable BROWSER) and a temporary workaround: https://stackoverflow.com/questions/65774451/vs-code-with-wsl-now-opens-the-browser-sh-file-instead-of-launching-the-browser – Daryn Feb 02 '21 at 06:16
  • Updating `react-scripts` to 4.0.2 seems to fix this on my computer. – Wes Lord Feb 09 '21 at 02:02

0 Answers0