Sitelet https://github.com/nodejs/node/issues/42469
Skip to content

Rename binary that supports ESM to node2 #42469

Description

@Raynos

What is the problem this feature will solve?

I'm currently using nodejs with require and commonjs,

I cannot require an .js file that uses ESM and it's a terrible user experience.

What is the feature you are proposing to solve the problem?

Can we remove ESM support from node and make a node2 binary that supports ESM ?

What alternatives have you considered?

Add the ability to require an ESM module.

Activity

  1. aduh95 commented on Mar 26, 2022

    @aduh95
    Contributor

    I'm not sure I understand the ask, even if we remove support for ESM and/or add a node2 binary, you still wouldn't be able to require an ESM file 🤔

  2. jasnell commented on Mar 26, 2022

    @jasnell
    Member

    If I understand the ask, it's for ./node to only ever work with commonjs and for ./node2 to only ever work with ESM. It's a python2/python3 type split. If that is indeed the ask, strong -1.

  3. added
    esmIssues and PRs related to the ECMAScript Modules implementation.
    on Mar 26, 2022
  4. bnb commented on Mar 27, 2022

    @bnb
    Contributor

    It's a python2/python3 type split.

    also strong -1 on this.

  5. benjamingr commented on Mar 27, 2022

    @benjamingr
    Member

    Is there an issue with passing a CLI flag to the node binary or adding a package.json with "type": "module"?

  6. Raynos commented on Mar 28, 2022

    @Raynos
    ContributorAuthor

    I'm building an application to run AWS style lambdas locally with support for multiple languages.

    When the user specifies their python file they choose python2 or python3.

    When the user specifies their nodejs javascript file they specify node12 / 14 / 16 etc. I then try to execute said nodejs file as a commonjs file by using require() .

    My customer is confused their nodejs file written in ESM does not work with my application, this is because ESM is a breaking change and they should have been forced to choose node or node2 to decide whether they want me to load a commonjs or esm program for local exection and AWS Lambda emulation.

    Alternatively, if I can require an ESM file then that would also not be a breaking change.

  7. devsnek commented on Mar 28, 2022

    @devsnek
    Member

    cpython (which is what I assume you're referring to) releases aren't named python2 or python3, that's done by distro packaging people (although by python foundation recommendation), and they do that because of backward compat (modifying old python scripts to use python2 in the interpreter directive). the esm problem is sort of the inverse of that, so I'm not sure how much sense the approach makes.

  8. RaisinTen commented on Mar 28, 2022

    @RaisinTen
    Member

    When the user specifies their nodejs javascript file they specify node12 / 14 / 16 etc. I then try to execute said nodejs file as a commonjs file by using require() .

    You could modify the input format to allow users to encode the module type and run the js file accordingly.

  9. aduh95 commented on Mar 28, 2022

    @aduh95
    Contributor

    When the user specifies their nodejs javascript file they specify node12 / 14 / 16 etc. I then try to execute said nodejs file as a commonjs file by using require() .

    You could modify the input format to allow users to encode the module type and run the js file accordingly.

    Alternatively you could use import(pathToFileurl(/sitelet?url=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2FpathToTheUserFile)), import() let's you load both CJS and ESM files. (Note that the file in question should use .cjs / .mjs extensions for this to work in all cases)

  10. moved this to Pending Triage in Node.js feature requestson Apr 4, 2022
  11. github-actions commented on Sep 25, 2022

    @github-actions
    Contributor

    There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.

    For more information on how the project manages feature requests, please consult the feature request management document.

  12. added
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Sep 25, 2022
  13. github-actions commented on Oct 25, 2022

    @github-actions
    Contributor

    There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment.

    For more information on how the project manages feature requests, please consult the feature request management document.

  14. moved this from Pending Triage to Stale in Node.js feature requestson Oct 25, 2022
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

    esmIssues and PRs related to the ECMAScript Modules implementation.feature requestIssues requesting new Node.js features.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions