ReferenceError: Can't find variable: global
See original GitHub issueMy build vite
vue3
and packages vue-router
and pinia
. I have tried a lot variants and even the simplest one throws the same error every time. When I try to initialize WallectConnectProvider like that:
import WalletconnectProvider from '@walletconnect/web3-provider'
async function connect() {
const config = {97: 'https://data-seed-prebsc-1-s1.binance.org:8545/'}
const wc = new WalletconnectProvider({rpc: config})
// await wc.enable()
}
Page immediately crushes with error: ReferenceError: Can't find variable: global
.
Seems like this problem appeared on vue3 + vite. I researched a lot and found that the problem possible on walletconnect
lib side
Repo for recreation of problem: vue-wc-problem
Node version 16.13.2
npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers
System:
OS: macOS 11.6.2
CPU: (4) x64 Intel(R) Core(TM) i5-4250U CPU @ 1.30GHz
Memory: 178.09 MB / 4.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.13.2 - ~/.nvm/versions/node/v16.13.2/bin/node
Yarn: 1.19.1 - /usr/local/bin/yarn
npm: 8.1.2 - ~/.nvm/versions/node/v16.13.2/bin/npm
Browsers:
Chrome: 97.0.4692.71
Safari: 15.2
npmPackages:
@vitejs/plugin-vue: ^2.0.1 => 2.1.0
vite: ^2.7.13 => 2.7.13
I have tried in dev and build modes same problem
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:11
Top Results From Across the Web
ReferenceError: Can't find variable: global #10824 - GitHub
A workaround fixed the issue: Workaround 1: add (windows as any).global = window to polyfills.ts; Workaround 2: add window.global = window to ...
Read more >ReferenceError: Can't find variable: globalThis - Stack Overflow
I have a angular 9 based website which is hosted in firebase. I have an issue which happens only on some devices like...
Read more >It keeps saying "Reference error: can't find variable"
It keeps saying "Reference error: can't find variable". This is my code: var userChoice = function(question) { question = prompt(“Do you choose rock,...
Read more >ReferenceError: "x" is not defined - JavaScript - MDN Web Docs
ReferenceError : "x" is not defined. The JavaScript exception "variable is not defined" occurs when there is a non-existent variable referenced somewhere.
Read more >Can't find variable: __scanCodes in React Native Vision Camera
ReferenceError : Can't find variable : __scanCodesPlease do like share and comment if you like the video please do hit like and if...
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
try this
As @armgit5 mentioned, this currently works: https://stackoverflow.com/questions/70714690/buffer-is-not-defined-in-react-vite
npm i @esbuild-plugins/node-globals-polyfill
Inside your
vite.config.js
file:Import the package:
And then add
optimizeDeps
to the config:Currently working as of 8/2/22 - Vite(2.9.12) / Vue 3(3.2.37)