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.

From 0.16.8 to 0.16.9 : ReferenceError: require is not defined

See original GitHub issue

Hi there,

I was using twind for quite some time on my project : https://github.com/Shuunen/what-now/

I’m using twind/shim for months without any issues via this 2 lines of code :

import { setup } from 'twind/shim'`
setup({ mode: 'silent' })

My project is in TypeScript, I build a iife package for web with tsup/esbuild.

Until recently, everything was working well, but the lastest upgrade from 0.16.8 to 0.16.9 has bring this error ReferenceError: require is not defined on my website.

If I rollback twind to 0.16.8 then build & deploy again : it works as expected, no more error

I looked at https://github.com/tw-in-js/twind/compare/v0.16.8...v0.16.9 , but it’s hard to see which commit introduced this, maybe the chore: deps upgrade a501131 ?

If we compare the 2 builds : 0.16.8 on the left & 0.16.9 on the right :

image

We can see that require("url") is appearing with the update, there are 2 other occurences of this same require on the build.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
sastancommented, Mar 28, 2021

No worries. Happy to help.

1reaction
Shuunencommented, Mar 28, 2021

@sastan thanks for all your explanations, I learnt a lot today, sorry that the issue belong to tsup in the end (see my previous comment)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Client on Node.js: Uncaught ReferenceError: require is not ...
However, require is not defined on the client side, and it throws an error of the form Uncaught ReferenceError: require is not defined...
Read more >
ReferenceError: require is not defined in JavaScript - Stack Diary
The "ReferenceError: require is not defined" error occurs when the require function is used in a JavaScript file that is intended to be ......
Read more >
[webpack-cli] referenceerror: require is not defined in es ...
I haven't verified this with node 13.x but in the stable 14.x and up whenever "type" is defined with value "module", it tells...
Read more >
ReferenceError: require is not defined #33741 - nodejs/node
Node returns error output stating that require is not defined. How often does it reproduce? Is there a required condition? All the time....
Read more >
How To Fix ReferenceError require is not defined in JavaScript
In this case, check your package.json file for an property called type . If that is set to module , ES6 modules will...
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