umi: createUmi causes error in browser
I am using SvelteKit. Just a basic SvelteKit template is good enough for reproducing this issue.
If the line of import below appears in the +page.svelte file, it will cause error.
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
The error
TypeError: import_os.homedir is not a function
It can be traced back to SolanaCliConfig from @soceanfi/solana-cli-config imported by umi-addsa-web3js. I don’t understand why SolanaCliConfig is needed for a client side library or why it is being included in the client side code.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 22 (10 by maintainers)
Thanks for sharing! I got it working by making these changes to
next.config.mjs:It has worked, Thanks
@beeman @aek676 looks like the umi package patch didn’t get released yet that I can see. Hold tight and I’ll get that pushed out to npm.
I’m having a look into this over the weekend for you all 😃
@beeman thank you so much!! this works totally fine, even with other Solana packages. I see in the last time the Sveltekit config doesn’t need to be so complicated like years ago to work with web3. 😃
@everythingspirals here is my temporary solution:
createWeb3JsEddsato my own code and stub out the 2 functions:createKeypairFromFile,createKeypairFromSolanaConfig.createUmito my own code and use my customcreateWeb3JsEddsaabove.The library should have just accept Uint8Array keypair and leave the loading key from file to the library user.