fable-node icon indicating copy to clipboard operation
fable-node copied to clipboard

consider using `node:` import prefixes

Open joprice opened this issue 7 months ago • 0 comments

When attempting to run some code making use of the fs builtin via deno, I get the error

error: Relative import path "fs" not prefixed with / or ./ or ../
If you want to use a built-in Node module, add a "node:" prefix (ex. "node:fs").

Versions of since 16 and >= 14.18 have support for prefixed builtins https://nodejs.org/api/modules.html#built-in-modules, so there is a compatibility concern.

You can work around this with deno (and possibly something similar for bun) by using import maps or --unstable-bare-node-builtins, but it is also mentioned in the Node docs using the prefixes has the benefit of avoiding another module of the same name unintentionally shadowing the builtin.

joprice avatar Jun 29 '24 14:06 joprice