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

algosdk is a CommonJS module #216

Closed
scholtz opened this issue Aug 19, 2024 · 3 comments · Fixed by #259
Closed

algosdk is a CommonJS module #216

scholtz opened this issue Aug 19, 2024 · 3 comments · Fixed by #259

Comments

@scholtz
Copy link
Contributor

scholtz commented Aug 19, 2024

After upgrade from v2 to v3 of the use-wallet I have started to receive error: SyntaxError: Named export 'Algodv2' not found. The requested module 'algosdk' is a CommonJS module, which may not support all module.exports as named exports.

image

we are using the nextjs with typescript, i have checked that the algosdk is correctly installed (2.8.0), i have tried to downgrade it, i have tried to reinstall the node modules...

the error originates in the use wallet lib.. for the record i can use import { Algodv2 } from "algosdk"; in my project

image

i have checked the example project here and dont see any typescript difference.. https://github.com/TxnLab/use-wallet/blob/main/examples/nextjs/tsconfig.json

anybody has faced the same issue before?

@TheGateKeeper1995
Copy link

I'm getting the same issue, but not on typescript, and with Next Js as well

@scholtz
Copy link
Contributor Author

scholtz commented Aug 26, 2024

i fixed my issue by upgrading the nextjs and changing the filesystem structure

before it was not using the src folder, so i moved everything to src updated a lot of other configs (eg tailwind, typescript..) and it seems to work now

basically i moved from /pages/index.tsx to /src/app/page.tsx which fixed the issue

@SilentRhetoric
Copy link
Contributor

I am encountering the same error in SolidStart.

I believe that the issue can be resolved with a small change here:

https://github.com/TxnLab/use-wallet/blob/1dd8f538d77167382884074499a3c522fed78fa3/packages/use-wallet/src/store.ts#L1C1-L1C34

- import { Algodv2 } from 'algosdk'
+ import algosdk from 'algosdk'
+ const { Algodv2 } = algosdk 

drichar added a commit that referenced this issue Sep 12, 2024
This commit changes the import of `Algodv2` from `algosdk` to use the default import syntax. This resolves a SyntaxError in consuming apps that use CommonJS modules.

Closes #216
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

Successfully merging a pull request may close this issue.

3 participants