Uncaught ReferenceError: globalThis is not defined
See original GitHub issue🐛 bug report
Compiling a package with Node (or Electron-renderer) context and using it triggers this error in some cases.
ReferenceError: globalThis is not defined
at /packages/linter-ui-default/dist/index.js:1:7989
at Se (/packages/linter-ui-default/dist/index.js:1:8142)
at oi (/packages/linter-ui-default/dist/index.js:1:44368)
at _e (/packages/linter-ui-default/dist/index.js:1:15274)
at _e (/packages/linter-ui-default/dist/index.js:1:7948)
at st (/packages/linter-ui-default/dist/index.js:1:15266)
at Qn.e.forEach.e (/packages/linter-ui-default/dist/index.js:1:83011)
at Array.forEach (<anonymous>)
at /packages/linter-ui-default/dist/index.js:1:82976)
at mn.updateTooltip (/packages/linter-ui-default/dist/index.js:1:89363)
at textEditor.onDidChangeCursorPosition (/packages/linter-ui-default/dist/index.js:1:88651)
at /packages/linter-ui-default/dist/index.js:1:41580)
at /packages/linter-ui-default/dist/index.js:1:41857)
at /packages/linter-ui-default/dist/index.js:1:41746)
🎛 Configuration (.babelrc, package.json, cli command)
"engines": {
"atom": ">=1.19.0 <2.0.0",
"electron": ">=5.x"
},
"targets": {
"main": {
"context": "node",
"includeNodeModules": {
"atom": false,
"electron": false,
"atom-package-deps": false,
"disposable-event": false
},
"outputFormat": "commonjs",
"isLibrary": true
}
},
"build": "cross-env NODE_ENV=production parcel build --target main ./lib/index.ts",
🤔 Expected Behavior
globalThis should not be needed?
😯 Current Behavior
Parcel generates globalThis
💁 Possible Solution
Use unbundled JS
🔦 Context
https://github.com/steelbrain/linter-ui-default/issues/617
💻 Code Sample
https://github.com/steelbrain/linter-ui-default
🌍 Your Environment
| Software | Version(s) |
|---|---|
| Parcel | “parcel”: “2.0.0-nightly.562”, |
| Node | 12 |
| npm/Yarn | 6 |
| Operating System | win 10 |
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (17 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 Free
Top 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

I’m also somewhat surprised that
@babel/preset-envdoesn’t handle globalThis…TIL: preset-env doesn’t really transpile API, only syntax. So we should transpile
globalThisourselves just likeglobal(but probably only when it’s unsupported)