Open alexjg opened 3 years ago
I experienced the same issue. The workaround that I found is the following:
Importing in Node (version>12):
// @ts-ignore
import multiformats from 'multiformats/basics'
// @ts-ignore
import legacy from 'multiformats/legacy'
Importing in jest
tests:
import basicsImport from 'multiformats/cjs/src/basics-import.js'
import legacy from 'multiformats/cjs/src/legacy.js'
ESM modules are not supported in Jest as well. This is the link the reference.
I just ran into an issue where I was using an older version of Node (12.16.1) and getting a
"Cannot find module 'multiformats'"
error after installation. This seems to be because of the use of ESM modules, which are only be supported in the latest version of node. It's probably worth adding a note about this to the README as otherwise it's very difficult to debug.