Skip to content

require throws, but require.resolve does not #43274

Closed
@ljharb

Description

@ljharb

Version

16.15.0

Platform

Darwin computername.local 20.6.0 Darwin Kernel Version 20.6.0: Wed Jan 12 22:22:42 PST 2022; root:xnu-7195.141.19~2/RELEASE_X86_64 x86_64

Subsystem

node:readline/promises

What steps will reproduce the bug?

  1. run node -pe "require.resolve('readline/promises2')" and node -pe "require('readline/promises2')". Observe that both throw.
  2. run node -pe "require('node:readline/promises')". Observe that it throws "no such builtin module".
  3. run node -pe "require.resolve('node:readline/promises')" or node -pe "require.resolve('node:readline/promises2'), and instead of throwing, both print the given specifier.

Modules that are not requireable must NEVER be require.resolveable; that's part of the contract of require.

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior?

No response

What do you see instead?

See above.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.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