Created
August 25, 2025 01:17
-
-
Save sefgit/4d92daa055fa6e4666dc24c6e060ad90 to your computer and use it in GitHub Desktop.
vite Buffer issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| npm install buffer | |
| import { Buffer } from 'buffer'; | |
| globalThis.Buffer = Buffer; | |
| npm install -D vite-plugin-node-polyfills | |
| Configure it in vite.config.js or vite.config.ts: | |
| import { defineConfig } from 'vite'; | |
| import { nodePolyfills } from 'vite-plugin-node-polyfills'; | |
| export default defineConfig({ | |
| plugins: [ | |
| nodePolyfills({ | |
| // To enable Buffer polyfill | |
| globals: { | |
| Buffer: true, | |
| }, | |
| }), | |
| ], | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment