Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "Buffer2 is undefined" when using userbase-js with SvelteKit #356

Open
zPhoeniqz opened this issue Apr 27, 2022 · 3 comments
Open

Comments

@zPhoeniqz
Copy link

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'

@j-berman
Copy link
Collaborator

j-berman commented Apr 30, 2022

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.

@BlakeEric
Copy link

+1 for this. Is there any workaround that can be used in the meantime?

@j-berman
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants