Skip to content

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

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?

Activity

  1. changed the title [-]repl.builtinModules doesn't contain all node.js builtin modules[/-] [+]`repl.builtinModules` doesn't contain all node.js builtin modules[/+] on Mar 16, 2025
  2. aduh95 commented on Mar 16, 2025

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

    SGTM, would you like to send a PR?

  3. dario-piotrowicz commented on Mar 16, 2025

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

    SGTM, would you like to send a PR?

    Yes for sure! I'll get to it right away, but could you clarify the plan here? is the idea to land this as a breaking change for v24 and leave it as is in v23?

    Or if it makes sense I can fix and deprecating it in v23 and remove it altogether in v24, if that's not too much overhead

    But I am not sure how to do that (2 PRs one for v23 and one for v24?) could you advice me on how to proceed in this regard? 🙂 🙏

  4. dario-piotrowicz commented on Mar 16, 2025

    @dario-piotrowicz
    MemberAuthor

    Actually sorry it's my bad, _builtinLibs has been deprecated but not actually removed:

    node/lib/repl.js

    Lines 1871 to 1885 in ab9660b

    ObjectDefineProperty(module.exports, '_builtinLibs', {
    __proto__: null,
    get: pendingDeprecation ? deprecate(
    () => _builtinLibs,
    'repl._builtinLibs is deprecated. Check module.builtinModules instead',
    'DEP0142',
    ) : () => _builtinLibs,
    set: pendingDeprecation ? deprecate(
    (val) => _builtinLibs = val,
    'repl._builtinLibs is deprecated. Check module.builtinModules instead',
    'DEP0142',
    ) : (val) => _builtinLibs = val,
    enumerable: false,
    configurable: true,
    });

    So if we want to follow that I guess the correct solution here is to just deprecate repl.builtinModules instead of remove it altogether, right? 🤔

  5. aduh95 commented on Mar 16, 2025

    @aduh95
    Contributor

    The first step is to doc-deprecate it, you can check the history of deprecations.md for examples

  6. dario-piotrowicz commented on Mar 16, 2025

    @dario-piotrowicz
    MemberAuthor

    @aduh95 thanks, done 🙂👍

    Please have a look: #57508 🙏

    PS: the PR is only deprecating the field, I can update the PR to also fix it (basically making it an alias to module.builtinModules), should I? 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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