Search code examples
reactjswebpackhere-api

ReferenceError: _webpack_require_ is not defined


I am trying to do this guide Here React JS API, but I always just get a white screen with the here watermark and without a map and this error to.

ReferenceError: _webpack_require_ is not defined 2 6c60a8cc-4769-4b0e-932b-dbe27b7df713:1676:33
<anonym> blob:http://localhost:3000/6c60a8cc-4769-4b0e-932b-dbe27b7df713:1676
<anonym> blob:http://localhost:3000/6c60a8cc-4769-4b0e-932b-dbe27b7df713:18966
<anonym> blob:http://localhost:3000/6c60a8cc-4769-4b0e-932b-dbe27b7df713:18967

Does someone know what to do?

Env:

WSL 2 : Ubuntu 20.04 LTS

Node v16.13.0

Npm 8.1.0


Solution

  • The way to resolve this issue is, add the react-app-rewired dependency to your project, and then add to your root folder a config-overrides.js file with the following contents:

    module.exports = function override(config, env) {
        config.node = { global: false }
        return config
    }
    

    Finally, change the start script in package.json to use react-app-rewired, the scripts object should look like this:

    "scripts": {
        "start": "react-app-rewired start",
        "build": "react-scripts build",
        "test": "react-scripts test",
        "eject": "react-scripts eject"
      }