Archived Content from Web3Auth Community
This topic was originally posted by abhishek.sagu on 8/30/2024.
This content has been migrated from our previous community forum to preserve valuable discussions.
I am trying to follow the login given in example at web3auth-core-kit-examples/single-factor-auth-web/sfa-web-custom-jwt-example at main · Web3Auth/web3auth-core-kit-examples · GitHub . I wanted to add it in a create-react-app i already had. Installing @web3auth/ethereum-provider here gave me some error and the docs also said that create-react-app is deprecated , so i tried to convert it to vite app. I followed the guide at How to Migrate from Create React App to Vite . Now i am getting this issue which i am unable to debug
Uncaught SyntaxError: Identifier ‘Buffer’ has already been declared (at @web3auth_ethereum-provider.js?v=66ae6f42:114:3)
here is my vite.config.js file (i have used js instead of ts for my project)
/* eslint-disable import/no-extraneous-dependencies */
import react from “@vitejs/plugin-react”;
import { defineConfig } from “vite”;
import inject from “@rollup/plugin-inject”;
import { NodeGlobalsPolyfillPlugin } from “@esbuild-plugins/node-globals-polyfill”;
import { NodeModulesPolyfillPlugin } from “@esbuild-plugins/node-modules-polyfill”;
export default defineConfig({
plugins: [
react(),
inject({
Buffer: [“buffer”, “Buffer”],
include: “**/*.js”, // Ensure Buffer is only injected in .js files
}),
],
resolve: {
alias: {
buffer: “buffer”,
},
},
define: {
global: “globalThis”,
},
optimizeDeps: {
esbuildOptions: {
define: {
global: “globalThis”,
},
plugins: [
NodeGlobalsPolyfillPlugin({
buffer: true,
}),
NodeModulesPolyfillPlugin(),
],
},
},
});
How do i fix this issue ? Can someone please help me with this. Thanks

