The @zilliqa-js/crypto library in any Next.js project throws the error: The Module not found: Can't resolve 'fs'.
To Reproduce
Create a boilerplate Next.js project.
Run yarn dev to see if everything is working.
Install @zilliqa-js/crypto (tested with 3.3.3 and 3.3.0).
Use any function, tested with fromBech32Address in any file.
Run yarn dev again to see the The Module not found: Can't resolve 'fs' error.
Expected behavior
It should not throw error for using a function.
OS: Mac
Browser: Brave
Additional context
It may be due to Next.js mixing some server-side rendering (although the example does not do that) or the library expecting the filesystem library in wrong places.
Describe the bug
The
@zilliqa-js/crypto
library in any Next.js project throws the error:The Module not found: Can't resolve 'fs'
.To Reproduce
yarn dev
to see if everything is working.@zilliqa-js/crypto
(tested with 3.3.3 and 3.3.0).fromBech32Address
in any file.yarn dev
again to see theThe Module not found: Can't resolve 'fs'
error.Expected behavior
It should not throw error for using a function.
Additional context
It may be due to Next.js mixing some server-side rendering (although the example does not do that) or the library expecting the filesystem library in wrong places.
Interestingly,
zilPay.crypto.fromBech32Address
works from https://github.com/zilpay/zil-pay.