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

running client code in browser: os__WEBPACK_IMPORTED_MODULE_6__.homedir is not a function #17

Open
JimLynchCodes opened this issue Nov 21, 2024 · 1 comment

Comments

@JimLynchCodes
Copy link
Contributor

The very first line of crypto stuff in the client code here makes this call to the "loadEnv" function of switchboard's AnchorUtils object:

const { keypair, connection, program } = await sb.AnchorUtils.loadEnv();

But when I run this in the browser I see this error...

Uncaught runtime errors:
×
ERROR
os__WEBPACK_IMPORTED_MODULE_6__.homedir is not a function
TypeError: os__WEBPACK_IMPORTED_MODULE_6__.homedir is not a function
    at AnchorUtils.<anonymous> (http://localhost:3000/static/js/bundle.js:32247:107)
    at Generator.next (<anonymous>)
    at http://localhost:3000/static/js/bundle.js:32175:67
    at new Promise (<anonymous>)
    at __webpack_modules__../node_modules/@switchboard-xyz/on-demand/dist/esm/anchor-utils/AnchorUtils.js.__awaiter (http://localhost:3000/static/js/bundle.js:32157:10)
    at AnchorUtils.loadEnv (http://localhost:3000/static/js/bundle.js:32246:12)
    at startRoll (http://localhost:3000/static/js/bundle.js:330:81)
    at onClick (http://localhost:3000/static/js/bundle.js:227:102)
    at HTMLUnknownElement.callCallback (http://localhost:3000/static/js/bundle.js:89951:18)
    at Object.invokeGuardedCallbackDev (http://localhost:3000/static/js/bundle.js:89995:20)

The example coinflip typescript code works for me when I run it on the command line but not in the browser.

I already solved some other errors trying to port this node client to the browser by creating a config-overrides.js with things like os: require.resolve("os-browserify"), but I'm still getting this error now and stuck on how to get past it. 😕

Thanks!

@mgild
Copy link
Contributor

mgild commented Nov 21, 2024

This function is to pull configs from the solana cli. You can init the anchor program using the anchor sdk instead

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

2 participants