userbase
userbase copied to clipboard
Error "Buffer2 is undefined" when using userbase-js with SvelteKit
Full error message:
Buffer2 is undefined
node_modules/safe-buffer/index.js@http://localhost:3000/node_modules/.vite/deps/userbase-js.js?v=4f8aa8dd:174:9
__require@http://localhost:3000/node_modules/.vite/deps/chunk-QOVRSCHT.js?v=4f8aa8dd:11:50
node_modules/randombytes/browser.js@http://localhost:3000/node_modules/.vite/deps/userbase-js.js?v=4f8aa8dd:230:19
__require@http://localhost:3000/node_modules/.vite/deps/chunk-QOVRSCHT.js?v=4f8aa8dd:11:50
node_modules/diffie-hellman/lib/generatePrime.js@http://localhost:3000/node_modules/.vite/deps/userbase-js.js?v=4f8aa8dd:3261:23
__require@http://localhost:3000/node_modules/.vite/deps/chunk-QOVRSCHT.js?v=4f8aa8dd:11:50
node_modules/diffie-hellman/browser.js@http://localhost:3000/node_modules/.vite/deps/userbase-js.js?v=4f8aa8dd:3543:25
__require@http://localhost:3000/node_modules/.vite/deps/chunk-QOVRSCHT.js?v=4f8aa8dd:11:50
@http://localhost:3000/node_modules/.vite/deps/userbase-js.js?v=4f8aa8dd:6155:37
To reproduce:
npm init svelte@next
npm install
npm install userbase-js
Edit the index.svelte file. Add following line:
import userbase from 'userbase-js'
Going to look into removing the diffie-hellman dependency since it shouldn't be in use anymore anyway (was only used in userbase-js v1), thanks for reporting.
+1 for this. Is there any workaround that can be used in the meantime?
One workaround in the meantime could be to import the script from https://sdk.userbase.com/2/userbase.js
I'm not too familiar with Svelte, but this post seems a solid guide on going about doing that