Buffer is not defined | Vite
See original GitHub issueHello,
I’m facing an issue which I, after hours of trying, can not solve.
“@walletconnect/web3-provider”: “^1.6.6”,
making use of rollup-plugin-polyfill-node
as suggested in some posts, does not work. Any idea how to solve this issue?
I already make use of:
<body>
<!-- This is a hack to make web3 / walletconnect working with vite -->
<script>window.global = window;</script>
<script type="module">
import process from "process";
// import { Buffer } from "buffer";
import { Buffer } from 'safe-buffer'
import EventEmitter from "events";
window.Buffer = Buffer;
window.process = process;
window.EventEmitter = EventEmitter;
window.Buffer = window.Buffer || require('buffer').Buffer;
</script>
<div id="app" class="w-full bg-black"></div>
<script type="module" src="/src/main.ts"></script>
</body>
Issue Analytics
- State:
- Created 2 years ago
- Comments:8
Top Results From Across the Web
Buffer is not defined in React-vite - Stack Overflow
I try to add plugins, add define for Buffer, but it's not work. const viteConfig = defineConfig({ /* define: { "Buffer": {} },*/...
Read more >vue3+vite reports Uncaught ReferenceError: Buffer is not ...
Buffer is used for data conversion in the vue3+vite project, and the running project reports Uncaught ReferenceError: Buffer is not defined ...
Read more >Migrating our React setup to Vite - by Darko Atanasovski
First issues with the new setup The most common errors were: Buffer or process are not defined. These functions/constants are used by the ......
Read more >Buffer is not defined. Using Phantom Wallet, Solana and ...
I pick a working project from a friend and set mine to have the same settings. What I could say for sure is...
Read more >vite出现global is not defined和Buffer is not defined的解决方法
在vite搭建的脚手架当中使用tron的插件tronweb的时候,会出现如下警告:. 进行交易发送的时候,会出现如下报错,并且导致交易失败:. 解决方法如下:.
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
Hey guys. I found another solution to this problem. I simply import wallet connect via:
import WalletConnectProvider from '@walletconnect/web3-provider/dist/umd/index.min.js';
and to get the types working, I made a d.ts file with:declare module '@walletconnect/web3-provider/dist/umd/index.min.js' { import WalletConnectProvider from '@walletconnect/web3-provider/dist/esm/index'; export default WalletConnectProvider }
I got it 😃
That’s how my config looks:
and my body: