ElementsProject / libwally-core

Useful primitives for wallets
Other
282 stars 135 forks source link

TypeError: createRequire is not a function if want to use wally in nextjs project #440

Closed goran-markovic85 closed 8 months ago

goran-markovic85 commented 8 months ago

Using in same way like is in example:

import wally from 'wallycore'
const word = wally.bip39_get_word(null, 10)

NextJs error is:

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

and in terminal: ⨯ TypeError: createRequire is not a function at eval (webpack-internal:///(rsc)/../../node_modules/wallycore/libwally_wasm/wallycore.js:39:27) at async eval (webpack-internal:///(rsc)/../../node_modules/wallycore/src/core.js:20:16)

NextJS 13.4.12 Typescript "wallycore": "1.0.0",

jgriffiths commented 8 months ago

This appears to be related to the node version in use, as in https://stackoverflow.com/questions/70390777/error-in-module-createrequire-is-not-a-function

jgriffiths commented 8 months ago

Node 16 is now end of life; wally has been updated to build with node 20 and does not appear to have the issue.

Please update your node version to v20 or later, and re-open if the issue persists, thanks.