I get this error when importing userbase-js into a svelte file. First I tried to use it via a script tag but then I got the error window is undefined when declaring let userbase = window.userbase. I thought it would probably be better anyway to use it via the npm package. But how to I fix this error?
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