vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.39k stars 26.78k forks source link

"R is not defined" webpack error when running in development #40010

Open ItzDerock opened 2 years ago

ItzDerock commented 2 years ago

Verify canary release

Provide environment information

    Operating System:
      Platform: win32
      Arch: x64
      Version: Windows 10 Pro
    Binaries:
      Node: 18.6.0
      npm: N/A
      Yarn: N/A
      pnpm: N/A
    Relevant packages:
      next: 12.2.6-canary.5
      eslint-config-next: 12.1.6
      react: 18.2.0
      react-dom: 18.2.0

also tested on arch on a different device, and in a fresh docker development environment

What browser are you using? (if relevant)

Edge 104.0.1293.63, Chrome 104.0.5112.102

How are you deploying your application? (if relevant)

only affects development

Describe the Bug

Uncaught ReferenceError: R is not defined
    at webpack.js?ts=1661603528694:255:23
    at webpack.js?ts=1661603528694:256:12
    at webpack.js?ts=1661603528694:401:12

occurring at

/* webpack/runtime/hot module replacement */
/******/    !function() {
/******/        var k={},_=R,H,b=[],p=[],d="idle",w=0,D=[],l,v;F=k,C.push(function(e){var r=e.module,a=$(e.require,e.id);r.hot=x(e.id,r),r.parents (... trimmed)
                                ^^^^
/******/    }();

and the page remains blank

Expected Behavior

The page should load without any errors.

Link to reproduction

https://github.com/diced/zipline

To Reproduce

Unfortunately, I don't have a minimal reproduceable example, not very familiar with the codebase yet so I don't know what introduced this bug.

  1. Clone https://github.com/diced/zipline
  2. Run npm install (or any package manager)
  3. copy .env.local.example -> .env.local
  4. remove s3 and swift datasource from .env (remove any DATASOURCE_TYPE={s3,swift})
  5. change CORE_SECRET to anything
  6. and set a postgres db in CORE_DATABASE_URL (schema will automatically be pushed to database, so no extra setup needed)
  7. run prisma generate (or prefix with npx if prisma not installed globally)
  8. run npm run dev, and head to http://localhost:3000
  9. observe
ItzDerock commented 2 years ago

this problem goes away only in node 16.16.0 18, and later releases of 16 all have this issue.

working environment:

    Operating System:
      Platform: linux
      Arch: x64
      Version: #1 SMP Wed Mar 2 00:30:59 UTC 2022
    Binaries:
      Node: 16.16.0
      npm: 8.11.0
      Yarn: 3.2.1
      pnpm: N/A
    Relevant packages:
      next: 12.2.5
      eslint-config-next: 12.1.6
      react: 18.2.0
      react-dom: 18.2.0
AhmedBHameed commented 2 years ago

I confirm this issue. I tried node v16.16.0 also does not work.