You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Taking inspiration from nix, cargo, and python I would like a way for stand-alone scripts to embed configuration normally passed via package.json, node.config.json, argv, or wrapper scripts.
#59565 asks to support typescript-module in extensionless files but proposals for #!/usr/bin/env node --ext mts were rejected because many systems don't support multi-word shebangs.
I don't think this limitation is exclusive to that --ext use cases, there are other options including --permission that cannot be set in a self contained script, yes you can use .env, node.config.json, or package.json but that's no-longer self contained.
This would also be an interesting integration point for package managers that could read dependencies from the frontmatter and support npm x ./script to install the script's inline dependencies.
What is the feature you are proposing to solve the problem?
The rough outline is for node to parse a leading comment in the main entry point and read command line arguments,
node.config, and package.json fields. The comment would only be read in the main entry point and would sit after explicit options in priority.
I would be happy with a more limited implementation that just solves the argv / shebang splitting problem, to allow portable scripts to pass args to their node process.
But I don't think either version would significantly slow script execution
It's just the main entry point, not every file
It's just the first lines, till a syntax error or line that doesn't start with // or a special marker we choose.
It's not building a JS AST, something smaller like JSON parsing
Activity
avivkeller commentedon Jul 29, 2026
Wouldn't this require AST parsing every script? that would dramatically slow down node, would it not?
avivkeller commentedon Jul 29, 2026
IMHO the multi-word sheband makes sense, and then it becomes the system's responsibility
everett1992 commentedon Jul 29, 2026
I would be happy with a more limited implementation that just solves the argv / shebang splitting problem, to allow portable scripts to pass args to their node process.
But I don't think either version would significantly slow script execution
//or a special marker we choose.