Skip to content

Instantly share code, notes, and snippets.

@sefgit
Created August 25, 2025 01:17
Show Gist options
  • Save sefgit/4d92daa055fa6e4666dc24c6e060ad90 to your computer and use it in GitHub Desktop.
Save sefgit/4d92daa055fa6e4666dc24c6e060ad90 to your computer and use it in GitHub Desktop.
vite Buffer issue
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