question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ReferenceError: __webpack_require__ is not defined

See original GitHub issue

Describe the bug

Hi!

I’m not sure yet if this is a bug in webpack or in vanilla-extract, but I haven’t seen this problem 5 days ago when I did test it out with https://github.com/gatsbyjs/gatsby/pull/35166. I’ve now re-run our example site https://github.com/gatsbyjs/gatsby/tree/master/examples/using-vanilla-extract and it fails with these kinds of errors:

ERROR in ./src/styles/404.css.ts
Module build failed (from ./node_modules/@vanilla-extract/webpack-plugin/loader/dist/vanilla-extract-webpack-plugin-loader.cjs.js):
ReferenceError: __webpack_require__ is not defined
    at eval (webpack-internal:///./src/styles/404.css.ts:1:1)
    at eval (<anonymous>)
    at Object../src/styles/404.css.ts (/Users/lejoe/code/work/gatsby/examples/using-vanilla-extract/src/styles/404.css.ts:21:1)
    at __webpack_require__ (/Users/lejoe/code/work/gatsby/examples/using-vanilla-extract/src/styles/404.css.ts:67:42)
    at /Users/lejoe/code/work/gatsby/examples/using-vanilla-extract/src/styles/404.css.ts:123:37
    at /Users/lejoe/code/work/gatsby/examples/using-vanilla-extract/src/styles/404.css.ts:126:12
    at Script.runInContext (node:vm:139:12)
    at Script.runInNewContext (node:vm:144:17)
    at Object.module.exports [as default] (/Users/lejoe/code/work/gatsby/examples/using-vanilla-extract/node_modules/eval/eval.js:71:12)
    at Object.processVanillaFile
(/Users/lejoe/code/work/gatsby/examples/using-vanilla-extract/node_modules/@vanilla-extract/integration/dist/vanilla-extract-integration.cjs.dev.js:108:50)
    at
/Users/lejoe/code/work/gatsby/examples/using-vanilla-extract/node_modules/@vanilla-extract/webpack-plugin/loader/dist/vanilla-extract-webpack-plugin-loader.cjs.dev.js:60:38
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at runNextTicks (node:internal/process/task_queues:65:3)
    at processImmediate (node:internal/timers:437:9)

I’ve tested it out with older Gatsby versions, back to 4.9.0, same error. So I currently suspect that it might be a webpack/vanilla-extract issue?

I’ve also tried pinning vanilla-extract to older versions but still no dice.

"@vanilla-extract/babel-plugin": "1.1.4",
"@vanilla-extract/css": "1.6.7",
"@vanilla-extract/webpack-plugin": "2.1.5",

Link to reproduction

https://github.com/gatsbyjs/gatsby/tree/master/examples/using-vanilla-extract

Run yarn and then yarn develop.

System Info

  System:
    OS: macOS 12.3
    CPU: (10) arm64 Apple M1 Pro
    Memory: 406.86 MB / 16.00 GB
    Shell: 5.8.1 - /opt/local/bin/zsh
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    Yarn: 1.21.0 - ~/.nvm/versions/node/v16.13.0/bin/yarn
    npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
  npmPackages:
    @vanilla-extract/css: ^1.6.8 => 1.6.8
    @vanilla-extract/webpack-plugin: ^2.1.6 => 2.1.6

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:6
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
LekoArtscommented, Mar 24, 2022

eval@0.1.8 was published, we should try if that fixed it (I can try later myself if no one gets to it)

3reactions
72636ccommented, Mar 24, 2022

I performed some lockfile surgery and I think I’ve narrowed this down to eval@0.1.7. Can you try locking to eval@0.1.6?

Read more comments on GitHub >

github_iconTop Results From Across the Web

webpack : Uncaught ReferenceError: require is not defined
in web app. According to https://github.com/liady/webpack-node-externals it is only for backend. Since you use nodeExternals in web app ...
Read more >
How To Fix ReferenceError require is not defined in JavaScript
The Solution. Your ReferenceError: require is not defined likely has one of two causes: You tried using require in a browser environment ......
Read more >
Uncaught ReferenceError: require is not defined #17 - GitHub
When I add this to my commonconfig in webpack, it throws this error. I can't understand why is it occurring or how to...
Read more >
Fix "require is not defined" in JavaScript/Node - Stack Abuse
You're trying to use require in a file ending in .mjs , which typically specifies ES modules. Node. If you encounter this error...
Read more >
How to fix the error `require is not defined` in Node.js
Today I started writing a new project on Node.js and got this error on the very first run: const express = require('express'); ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found