abi
abi2y ago

Deno and `npm:mongodb` problem with `node:`?

❯ deno check --reload main.ts
error: Relative import path "net" not prefixed with / or ./ or ../ and not in import map from "file:///Users/.../Library/Caches/deno/npm/registry.npmjs.org/mongodb/5.6.0/mongodb.d.ts"
If you want to use a built-in Node module, add a "node:" prefix (ex. "node:net").
at file:///Users/.../Library/Caches/deno/npm/registry.npmjs.org/mongodb/5.6.0/mongodb.d.ts:29:29
❯ deno check --reload main.ts
error: Relative import path "net" not prefixed with / or ./ or ../ and not in import map from "file:///Users/.../Library/Caches/deno/npm/registry.npmjs.org/mongodb/5.6.0/mongodb.d.ts"
If you want to use a built-in Node module, add a "node:" prefix (ex. "node:net").
at file:///Users/.../Library/Caches/deno/npm/registry.npmjs.org/mongodb/5.6.0/mongodb.d.ts:29:29
I'm simply importing stuff from npm:mongodb@5.6.0, why doesn't Deno understand this thing now?
1 Reply
abi
abiOP2y ago
❯ deno --version
deno 1.34.2 (release, aarch64-apple-darwin)
v8 11.5.150.2
typescript 5.0.4
❯ deno --version
deno 1.34.2 (release, aarch64-apple-darwin)
v8 11.5.150.2
typescript 5.0.4
I have also tried this with the same problem: deno cache --reload --no-lock --unstable main.ts No, actually I get almost the same problem, just a different import: error: Relative import path "events" not prefixed with / or ./ or ../ and not in import map from "file:///Users/.../Library/Caches/deno/npm/registry.npmjs.org/mongodb/5.6.0/mongodb.d.ts" I can import npm:mongodb just fine in Deno REPL, but not in my project... Never mind, I found the culprit: import { Sort } from "../../../../../../Library/Caches/deno/npm/registry.npmjs.org/mongodb/5.6.0/mongodb.d.ts"; 🤦‍♂️

Did you find this page helpful?