ReferenceError: global is not defined in runtime
See original GitHub issueDescribe the bug Error when executing the example code
SDK Version (if relevant) “@walletconnect/sign-client”: “2.1.3”, “typescript”: “^4.9.3”, “vite”: “^3.2.4”
To Reproduce
Checkout branch global-is-not-defined
of repo: https://github.com/smelnikov/walletconnect-sample
yarn install
npx vite
A runtime error appears:
Uncaught ReferenceError: global is not defined
at localStorage.js:49:3
at node_modules/localStorage/lib/localStorage.js (localStorage.js:54:1)
at __require2 (@walletconnect_sign-client.js?v=a6844a88:18:50)
at node_modules/@walletconnect/keyvaluestorage/dist/cjs/browser/index.js (index.ts:1:1)
at __require2 (@walletconnect_sign-client.js?v=a6844a88:18:50)
at index.js:1848:18
Expected behavior There are no errors in runtime.
Issue Analytics
- State:
- Created 10 months ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Uncaught ReferenceError: global is not defined #2141 - GitHub
ncaught ReferenceError: global is not defined at Object../node_modules/buffer/index.js (index.js:43) at webpack_require (bootstrap:76)
Read more >Upgrading to angular-6.x gives "Uncaught ReferenceError
Then you're getting the following error Fix: "Uncaught ReferenceError: global is not defined" do it as follows node: { global: true, ...
Read more >How to fix the ReferenceError: global is not defined error in ...
That sound simple enough to fix, just create a vite.config.[js/ts] file, add it to your SvelteKit project and define global right? // vite....
Read more >global is not defined react - You.com | The AI Search Engine ...
I did not need to install babel-runtime as other answers are suggesting. Open side panel. Uncaught ReferenceError: global is not defined at eval....
Read more >Error "global is not defined" with agent-js - DFINITY Forums
I get following error at runtime: Uncaught (in promise) ReferenceError: global is not defined The errors occurs there (minimized code and ...
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
@bkrem I solved this problem with define
global
variable during build https://github.com/smelnikov/walletconnect-sample/commit/a4e658ee2b6cfaa6b5de5447dacc54eff342267fBut it looks like this must be fixed at the top level of the library.
Thanks for raising this and especially including a repro for it @smelnikov 💯
While https://github.com/WalletConnect/walletconnect-utils/pull/36 will fix this type of issue for the code we (WalletConnect) own, this seems to be a reference in the
localStorage
dependency.Did some digging and found the
global
reference here: https://git.coolaj86.com/coolaj86/local-storage.js/src/branch/local-storage/lib/localStorage.js#L49cc @ganchoradkov, not sure what the best move here is, but I suspect we either: