Skip to content

repl.builtinModules doesn't contain all node.js builtin modules #57504

Closed
@dario-piotrowicz

Description

@dario-piotrowicz

Version

23.8.0

Platform

Ubuntu Mate 24.04.2 LTS (Linux 6.8.0-55-generic x86_64)

Subsystem

repl

What steps will reproduce the bug?

Run

node -e 'console.log(require("node:repl").builtinModules)'

and

node -e 'console.log(require("node:module").builtinModules)'

and notice how the modules printed in the first command are only a subset of those printed by the second

As you can see here:
screenshot of the two commands run in a terminal

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

It can be always reproduced and there is no required condition

What is the expected behavior? Why is that the expected behavior?

According to the REPL documentation (permalink) repl.builtinModules should contains a list of the names of all Node.js modules

What do you see instead?

Only a subset of the list

Additional information

  • (unless I'm mistaken) repl.builtinModules is basically just the same thing as the deprecated and removed repl._builtinLibs, in its deprecation note it is also stated that the list was incomplete

  • Modules not included in repl.builtinModules are available in the repl itself (e.g. node:test and node:sea)
    (so it's not like repl.builtinModules includes only modules available in the repl)

  • The deprecation note does recommend to use require('node:module').builtinModules instead, so maybe repl.builtinModules should just be deprecated and removed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions