Zilliqa / zilliqa-js

JavaScript SDK for Zilliqa blockchain
https://www.npmjs.com/package/@zilliqa-js/zilliqa
GNU General Public License v3.0
131 stars 74 forks source link

@zilliqa-js/crypto library is incompatible with a Next.js project #438

Closed RatulSaha closed 2 years ago

RatulSaha commented 2 years ago

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

  1. Create a boilerplate Next.js project.
  2. Run yarn dev to see if everything is working.
  3. Install @zilliqa-js/crypto (tested with 3.3.3 and 3.3.0).
  4. Use any function, tested with fromBech32Address in any file.
  5. 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.

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.