globalThis is not defined
See original GitHub issue“duplicate?”: Probably because of https://github.com/facebook/create-react-app/issues/10636
Describe the bug
When I use globalThis
I get the following error:
Did you try recovering your dependencies?
npm --version
7.10.0
Which terms did you search for in User Guide?
I searched globalThis
. While typing it was on global
and the autocomplete suggestions included this: https://create-react-app.dev/docs/using-global-variables/
which provides a workaround: Use window
instead. However i’d rather use globalThis
anyways.
Environment
(paste the output of the command here.)
PS C:\Users\Steven\Documents\code\js\sudoku\solver> create-react-app --info
Environment Info:
current version of create-react-app: 4.0.3
running from C:\Users\Steven\AppData\Roaming\npm\node_modules\create-react-app
System:
OS: Windows 10 10.0.19042
CPU: (4) x64 Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz
Binaries:
Node: 16.0.0 - C:\Program Files\nodejs\node.EXE
Yarn: Not Found
npm: 7.11.2 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 90.0.4430.93
Edge: Spartan (44.19041.906.0), Chromium (90.0.818.51)
Internet Explorer: Not Found
npmPackages:
react: ^17.0.2 => 17.0.2
react-dom: ^17.0.2 => 17.0.2
react-scripts: 4.0.3 => 4.0.3
npmGlobalPackages:
create-react-app: Not Found
Steps to reproduce
(Write your steps here:)
- use
globalThis
Expected behavior
(Write what you thought would happen.)
It would work
Actual behavior
(Write what happened. Please add screenshots!)
### Describe the bug
When I use `globalThis` I get the following error:
Reproducible demo
untested demo
// index.js
console.log(globalThis)
// <default code>
(Paste the link to an example project and exact instructions to reproduce the issue.)
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
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 - Microsoft Community
I am not able to access any files on Microsoft Teams and any time I try to ''globalThis' is not defined" keeps coming...
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 >'globalThis is not defined' in JSS Site - Rock, Paper, Sitecore
[NodeInvocationException: globalThis is not defined ReferenceError: globalThis is not defined at react.Component.react.Component.
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
The best solution is to import your variables if you can…
fixed with general dependency updates in create-react-app v5