Repository navigation
Rename binary that supports ESM to node2 #42469
Description
Activity
- addedfeature requestIssues requesting new Node.js features.Issues requesting new Node.js features.
on Mar 25, 2022 I'm not sure I understand the ask, even if we remove support for ESM and/or add a
node2binary, you still wouldn't be able to require an ESM file 🤔Reacted by Tierney CyrenIf I understand the ask, it's for
./nodeto only ever work with commonjs and for./node2to only ever work with ESM. It's apython2/python3type split. If that is indeed the ask, strong -1.Reacted by Jordan Harband- addedesmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.
on Mar 26, 2022 It's a python2/python3 type split.
also strong -1 on this.
Reacted by Jordan Harband and takipsizadIs there an issue with passing a CLI flag to the node binary or adding a package.json with
"type": "module"?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.
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
python2in the interpreter directive). the esm problem is sort of the inverse of that, so I'm not sure how much sense the approach makes.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.
Reacted by Benjamin GruenbaumWhen 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/.mjsextensions for this to work in all cases)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.
- addedstaleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
on Sep 25, 2022 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.
What is the problem this feature will solve?
I'm currently using nodejs with
requireand commonjs,I cannot require an
.jsfile 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
nodeand make anode2binary that supports ESM ?What alternatives have you considered?
Add the ability to require an ESM module.