Uncaught ReferenceError: globalThis is not defined
See original GitHub issueWhich 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.
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:
- Created a year ago
- Comments:6 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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 thelit
packages.