Skip to content

Describe alternatives to require.extensions #32483

Done

Description

@dilyanpalauzov

https://nodejs.org/api/modules.html#modules_require_extensions says require.extensions is deprecated.

Per TypeStrong/ts-node#641 and TypeStrong/ts-node#989 there are no alternatives. They reference further the documentation of @babel/node, @babel/register, and coffeescript.

• Either re-introduce require.extensions or describe more precisely the alternatiles that should be used.

Activity

  1. devsnek commented on Mar 25, 2020

    @devsnek
    Member

    The goal is for it to be replaced by loaders of some sort (like ESM)

  2. arpowers commented on Nov 20, 2020

    @arpowers

    I agree require.extensions should be "undeprecated" or a true alternative should be introduced.

  3. added
    deprecations
    module
    on Dec 26, 2020
  4. nyteshade commented on Feb 7, 2023

    @nyteshade

    Cannot agree more folks. The solution to be able to load custom extensions within an application by simply using require is pretty paramount. Please provide a sanctioned alternative, I could think of a few, or even a proper API around this.

    For example, you could even apply a chain of loaders for a specific extension allowing each to process the output of the previous before the final result appeared. Allowing conditional processing for extension functions and so on.

  5. jdmarshall commented on Feb 28, 2025

    @jdmarshall

    I'm trying to support someone on

    node-config/node-config#769

    And it appears that their problem is that neither Bun nor Node 22 added .ts to require.extensions. In node if .ts isn't registered, the library tries to load ts-node, but ts-node does not play nice with Bun.

    Everyone in the Node community needs a way to determine if third party library is needed to run TS or not.

    Node is the first ecosystem I've been in where deprecation warnings went in before the replacement was production ready.

    Deprecated since: v0.10.6

    Guys.. come on. This is just embarrassing.

  6. github-actions commented on Jun 27, 2026

    @github-actions
    Contributor

    This issue has been marked as stale due to 210 days of inactivity.
    It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

  7. added
    stale
    on Jun 27, 2026
  8. jdmarshall commented on Jun 27, 2026

    @jdmarshall

    The recent changes for type erasure have only made this situation more complex because there are subsets of TS that are valid but don't work with the erasure solution.

  9. removed
    stale
    on Jun 28, 2026
  10. github-actions commented on Sep 27, 2026

    @github-actions
    Contributor

    This issue has been marked as stale due to 90 days of inactivity.
    It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

  11. added
    stale
    on Sep 27, 2026
  12. jdmarshall commented on Sep 27, 2026

    @jdmarshall

    Deprecating something imparts a burden of effort to describe the workaround.

  13. removed
    stale
    on Sep 28, 2026
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

    deprecationsmodule

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions