Skip to content

Use the node: protocol in docs examples #38343

Closed
@sindresorhus

Description

@sindresorhus

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.moduleIssues 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