paulmillr / noble-secp256k1

Fastest 4KB JS implementation of secp256k1 signatures and ECDH
https://paulmillr.com/noble
MIT License
757 stars 114 forks source link

Got Error [ERR_REQUIRE_ESM] on import #115

Closed zzzh closed 1 year ago

zzzh commented 1 year ago

It says: Error [ERR_REQUIRE_ESM]: require() of ES Module /home/zhu/node_modules/@noble/secp256k1/index.js from /home/zhu/ts1/ecdh.js not supported.

Node.js version: v18.17.1 tsc version: v5.2.2 tsconfig.json comes from tsc --init

Any ideas?

paulmillr commented 1 year ago

You are doing require (commonjs), while the package only supports import (esm).

If you want to use commonjs, switch to https://github.com/paulmillr/noble-curves