-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
Closed
Labels
duplicateIssues and PRs that are duplicates of other issues or PRs.Issues and PRs that are duplicates of other issues or PRs.
Description
Is your feature request related to a problem? Please describe.
I like to write esm scripts that users can use in Node.js. Pre-esm Node would allow this & just work. But there does not seem to be an esm-supporting way to do this. Previously I could make a short script hello-world
:
#!/usr/bin/env node
console.log("yo")
And running it ./hello-world
would work. Today if I do that with an module type script, I get:
(node:83428) ExperimentalWarning: The ESM module loader is experimental.
internal/process/esm_loader.js:90
internalBinding('errors').triggerUncaughtException(
^
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension "" for /home/rektide/src/hello-world/hello-world
at Loader.defaultGetFormat [as _getFormat] (internal/modules/esm/get_format.js:65:15)
at Loader.getFormat (internal/modules/esm/loader.js:116:42)
at Loader.getModuleJob (internal/modules/esm/loader.js:247:31)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Loader.import (internal/modules/esm/loader.js:181:17)
at async Object.loadESM (internal/process/esm_loader.js:84:5) {
code: 'ERR_UNKNOWN_FILE_EXTENSION'
}
I do not want to subject my users to having to have every random utility I write end in .js: that adds no value to the user.
Describe the solution you'd like
Please allow unknown (or even just non-present) file extensions to be evaluated as javascript, using the same module or common heuristic as if it were a .js file.
Describe alternatives you've considered
- Continuing to have a really frustrating weird naming convention forced upon all our scripts 😭
- Content detection to intelligently pick format.
- Allow
--input-type=
to work even if a file is specified (presentlycan only be used with string input via --eval, --print, or STDIN
) - Detect argv[0] & if it is
nodecjs
nodemjs
nodewasm
nodenode
use the specified format. Symlink these names to the node binary.
Metadata
Metadata
Assignees
Labels
duplicateIssues and PRs that are duplicates of other issues or PRs.Issues and PRs that are duplicates of other issues or PRs.