Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for "node:" protocol for importing builtin nodejs modules #369

Closed
mortynex opened this issue Oct 29, 2021 · 2 comments
Closed

Support for "node:" protocol for importing builtin nodejs modules #369

mortynex opened this issue Oct 29, 2021 · 2 comments

Comments

@mortynex
Copy link

Is your feature request related to a problem? Please describe:
Many libraries make use of this feature, so not supporting would result in not being able to use these libraries.

Describe the solution you'd like:
Add the support for the protocol 😄

Describe alternatives you've considered:

Additional context:

node: is a protocol/prefix for importing a module to make clear that its node.js builtin module

example:

import fs from "node:fs/promises"
// or
const fs = require("node:fs/promises")

this feature was first introduced in node.js release v14.17.6, PR #37246

@jrvidal
Copy link
Contributor

jrvidal commented Nov 2, 2021

@mortynex AFAICS we do support this feature: https://stackblitz.com/edit/node-ccqtbh?file=index.mjs&terminal=start

@jrvidal jrvidal closed this as completed Nov 2, 2021
@d3lm
Copy link

d3lm commented Nov 2, 2021

@mortynex FWIW, this is only supported in ESM in Node 14 and not in CommonJS. As @jrvidal pointed out above, you can use type: module or, change index.js to index.mjs to run an ES module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants