Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Use the node: protocol in docs examples #38343

Copy link
Copy link
@sindresorhus

Description

@sindresorhus
Issue body actions

The node: protocol has many benefits:

  • Makes it perfectly clear that the import is a Node.js builtin module. (Beginners don't always realize this)
  • Makes the import identifier a valid absolute URL.
  • Avoids conflicts for future Node.js builtin modules.

However, most people don't know about the node: protocol. I suggest Node.js makes it the recommended way of importing builtin modules by using it in all the examples in the documentation. A lot of people are starting to move to ESM, so now would be a good time for people to switch to the node: protocol too.

Personally, I plan to switch all my packages to use the node: protocol. We have also made an ESLint rule for it.

fisker, mdboop, agucova, privatenumber, SvanBoxel and 210 moreaquaswim, markcarroll, MadProbe, radum and darovicqodunpob and liuliangsirSvanBoxel, satya164, szmarczak, sesam, bmealhouse and 15 morecjihrig, tonkotsuboy, matt-morris, einSelbst, sergiodxa-silverback and 5 morethescientist13, liuliangsir and jaydenseric

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.Issues and PRs related to the documentations.moduleIssues and PRs related to the module subsystem.Issues and PRs related to the module subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.