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.

Uncaught ReferenceError: globalThis is not defined

See original GitHub issue

Which package(s) are affected?

Lit Core (lit / lit-html / lit-element / reactive-element)

Description

Some users with old browsers get this error.

Uncaught ReferenceError: globalThis is not defined

It looks like reactive-element build for node always.

https://github.com/lit/lit/blob/ae6f6808f539254b72ec7efcff34b812173abe64/packages/reactive-element/rollup.config.js#L34

https://github.com/lit/lit/blob/ae6f6808f539254b72ec7efcff34b812173abe64/packages/reactive-element/src/reactive-element.ts#L1542

Reproduction

Use a old browser

Workaround

I have not found a workaround

Is this a regression?

No or unsure. This never worked, or I haven’t tried before.

Affected versions

2.2.1

Browser/OS/Node environment

Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3947.100 Safari/537.36

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
beijingbeefcommented, Aug 22, 2022

Thanks, the link you posted is very useful. I found out the root cause for my case. We have a mirror of all npm repositories. The approved version of reactive-element is still 1.3.4. There is no node build yet at 1.3.4 and globalThis is used in that version. https://github.com/lit/lit/blob/%40lit/reactive-element%401.3.4/packages/reactive-element/src/reactive-element.ts#L1524

Thanks for the help.

0reactions
augustjkcommented, Aug 20, 2022

I haven’t actually used it myself but I believe this is the setting: https://webpack.js.org/configuration/resolve/#resolveconditionnames I’m not sure what webpack’s default behavior is but the 'default' export condition is meant to be for browsers in the lit packages.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReferenceError: globalThis is not defined - npm - Stack Overflow
Consider updating your version of node.js to >=12 . globalThis was added in node.js v12.0.0 according to this compatibility table.
Read more >
ReferenceError: globalThis is not defined · Issue #2795 - GitHub
ReferenceError : globalThis is not defined at evalmachine.<anonymous>:1:1 at Script.runInContext (vm.js:133:20) at Object.
Read more >
globalThis is not defined although node version is v14.4.0
If you experience errors saying that globalThis is not defined, be sure to run a recent version of Node.js (at least 12.0). node...
Read more >
ReferenceError: globalThis is not defined - Ionic Framework
Hey guys its been weeks that my app was running great in broswer as serve or serve -l and on some android devices...
Read more >
ReferenceError: globalThis is not defined
Hey guys,. I am working on the ionic project and I am facing one issue. my app is working fine if I run...
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