0
votes

Create react app:

npx create-react-app --name=helloworld --use-npm

I then load the example

npm start

Visit the browser at localhost:3000 in both chrome and IE edge.

  • Expected: To see the vanilla react application
  • Actual: white screen, with syntax error

The following things I have tried in addition to the above and its still not working:

package.json

{
  "name": "helloworld",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@babel/polyfill": "^7.7.0",
    "@babel/preset-env": "^7.7.7",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.4.0",
    "@testing-library/user-event": "^7.2.1",
    "core-js": "^3.6.2",
    "react": "^16.12.0",
    "react-app-polyfill": "^1.0.5",
    "react-dom": "^16.12.0",
    "react-scripts": "3.3.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      "defaults",
      "ie 10"
    ],
    "development": [
      "defaults",
      "ie 10"
    ]
  }
}

.babelrc

{
    "presets": [
        [
"@babel/preset-env", {
      "useBuiltIns": "entry",
            "debug":true
        }]
    ]
}

index.js

import '@babel/polyfill';
import 'core-js';
import 'react-app-polyfill/ie9';
import 'react-app-polyfill/stable';
import 'react-app-polyfill/ie11';

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';

ReactDOM.render(<App />, document.getElementById('root'));
serviceWorker.unregister();
1

1 Answers

1
votes

ok this is a bug I've found, as printed in github . It's a hacky solution for now but this works. - https://github.com/facebook/create-react-app/issues/8084

  • ./node_modules/react-dev-utils/webpackHotDevClient.js:60 add slashes: true

example:

var connection = new WebSocket(
  url.format({
    protocol: 'ws',
    hostname: window.location.hostname,
    port: window.location.port,
    // Hardcoded in WebpackDevServer
    pathname: '/sockjs-node',
    slashes: true
  })
);