I'm working on a React project using Vite, and recently started encountering an error after installing the opensea-js package. The error message I'm seeing is:
Uncaught SyntaxError: Identifier 'Buffer' has already been declared (at chunk-EXX7LTSE.js?v=970d3bc1:19:3)
Here is the relevant part of my vite.config.ts:
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tsconfigPaths from 'vite-tsconfig-paths'
import svgrPlugin from 'vite-plugin-svgr'
import { NgmiPolyfill } from 'vite-plugin-ngmi-polyfill'
export default defineConfig({
envDir: './env',
plugins: [
react(),
tsconfigPaths(),
svgrPlugin(),
NgmiPolyfill({
rollupPolyfillOptions: {}
}),
],
resolve: {
alias: { timers: 'rollup-plugin-node-polyfills/polyfills/timers' },
},
build: {
sourcemap: true,
},
})
Package versions in package.json:
"buffer": "^6.0.3",
"opensea-js": "^5.0.2",
I have the buffer package installed in my project. My understanding is that opensea-js and possibly other dependencies are using the Buffer global, which is causing a conflict.
Has anyone encountered this issue before? What might be causing this conflict, and how can I resolve it?
I appreciate any insights or help!