ucan.storage
ucan.storage copied to clipboard
As is: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: ...
I am trying to implement in the backend Nestjs to create a UCAN token.
However, I have a problem with the
import { KeyPair } from 'ucan-storage/keypair’;
I can't get the import to work.
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module:
error occurs.
can you give a snippet of your code so we can better review this error ?
Any updates on this topic? I have the same problem with my expressJS application (using typescript)
Here is a snippet
import KeyPair from 'ucan-storage/keypair'
// KeyPair.create returns a promise, so it should be called from an async function or resolved with `.then`
async function createNewKeypair() {
const kp = await KeyPair.KeyPair.create()
// log the DID string for the public key to the console:
console.log(kp.did())
}
but as you can see it has been copy-pasted from the README.md file.
Any update on this? I have the same problem with a default nodejs express app (typescript, module: commonjs)
I made a commonJS library for UCAN as a solution for this: https://npmjs.com/package/ucan-storage-commonjs