Skip to content

Switch from node12 to node16 to avoid top-level await issues #48646

Closed

Description

Today, --moduleResolution node12 is a pit-of-failure experience because Node.js 12 is already oldish and doesn't support top-level await. This was brought up in #46452 (and in this comment #46452 (comment))

Before TypeScript 4.7 RC, we should remove node12 as an option and provide a node16 option instead.`

Activity

  1. weswigham commented on Apr 11, 2022

    @weswigham
    Member

    I get wanting a newer numbered node version (and am all for it); but is there a reason to remove the node12 support? It's the first node version with native esm support, and it has some important caveats in its resolution (in addition to the whole no-TLA thing) that are fixed or changed by later versions.

  2. DanielRosenwasser commented on Apr 12, 2022

    @DanielRosenwasser
    MemberAuthor

    It's the first node version with native esm support, and it has some important caveats in its resolution (in addition to the whole no-TLA thing) that are fixed or changed by later versions.

    The way I see it, every time a user has to decide between these, and every time we have to list every possible option, is a place where dropping node12 and starting at node14/node16 could improve those experiences. So let's not provide awkward middle grounds leading up to the experience that most users will want, and let's not obligate ourselves to supporting the caveats either of Node 12 either.

  3. weswigham commented on Apr 12, 2022

    @weswigham
    Member

    You don't see users wanting to support every node version that supports esm format source code?

  4. weswigham commented on Apr 12, 2022

    @weswigham
    Member

    Like, I'm all for nodenext being the preferred mode - you really don't have a good reason to not track latest node unless you're building for maximal compatibility.

  5. DanielRosenwasser commented on Apr 12, 2022

    @DanielRosenwasser
    MemberAuthor

    Well people need a stable target. I just think we have a decent amount of agreement on #46452 (comment) around dropping node12 in favor of a later version which would both allow us to shed some extra corner-cases and remove a step of friction for users.

  6. weswigham commented on Apr 12, 2022

    @weswigham
    Member

    node16 will be the first node version to support https imports in it's release line, as an FYI.

  7. weswigham commented on Apr 27, 2022

    @weswigham
    Member

    FYI Daniel Rosenwasser (@DanielRosenwasser) TLA in node is still documented as experimental even in 18 (though there's an open PR to stabilize it in the 18 timeframe since it's officially stabilized in v8). If we respect the docs, we shouldn't even allow TLA in a hypothetical node18 just yet.

  8. dnalborczyk commented on May 1, 2022

    @dnalborczyk

    Daniel Rosenwasser (@DanielRosenwasser) Wesley Wigham (@weswigham)
    node v12 has reached end-of-life April 30th 2022 https://nodejs.org/en/about/releases/ it's probably a good idea to drop node12 altogether and move to node16 directly for TypeScript v4.7.

  9. DanielRosenwasser commented on May 3, 2022

    @DanielRosenwasser
    MemberAuthor

    After this change, a nightly, RC, or stable version of TypeScript will issue the following error message:

    error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'.
    error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.
    

    Instead of node12, you should switch to node16 or nodenext.

  10. locked as resolved and limited conversation to collaborators on Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptDomain: ES ModulesThe issue relates to import/export style module behaviorFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions