I have this line in my file: import * as secp256k1 from "npm:@noble/secp256k1";
It works fine locally (deno run
)
When I try to deno deploy, it cannot find the module.
I read this is because deno deploy doesn't yet support npm:
.
To circumvent it I tried using import * as secp256k1 from "https://deno.land/x/secp256k1/mod.ts"
, but this doesn't work locally. I'm getting
error: Relative import path "crypto" not prefixed with / or ./ or ../
If you want to use a built-in Node module, add a "node:" prefix (ex. "node:crypto").
at https://deno.land/x/[email protected]/index.ts:6:29
how can I fix this? thanks.
The documentation for
/x/secp256k1
says:In this case, you will need to polyfill node's crypto. In the future this will be done using
node:crypto
, but for now deploy does not support this and you must usehttps://deno.land/[email protected]/node/crypto.ts
.Your import map should look something like:
Here is an example of using import maps with deploy (it's just how you would expect): https://github.com/satyarohith/import_map