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
{{ message }}
Repository navigation
doc: clarify process.argv[1] behavior for -e/--eval #61363
The first element will be [process.execPath][]. See process.argv0 if access to the original value of argv[0] is needed. The second element will be the path to the JavaScript file being executed. The remaining elements will be any additional command-line arguments.
This description is incomplete for no-script execution modes like -e/--eval (evaluating inline JavaScript).
When running Node.js with -e/--eval (e.g., node -e "console.log(process.argv[1])" "Hello world"), there is no "JavaScript file being executed". In reality, the command outputs "Hello world"—this behavior has been verified consistently on Windows 10 CMD and Linux Bash, proving process.argv[1] maps to the first unconsumed command-line argument, not a file path.
-e/--eval is a value-required built-in option, it's classified as exec_args (internal to Node.js, not exposed to process.argv).
Unconsumed arguments (e.g., "Hello world") are added to the args array, which maps to process.argv in the JS layer.
Proposed fix:
Revise the process.argv description to:
The first element will be [process.execPath][]. See process.argv0 if access to the original value of argv[0] is needed. The second element will be the path to the JavaScript file being executed (if a script file is provided). For no-script execution modes (e.g., -e/--eval), the second element is the first unconsumed command-line argument. The remaining elements are additional command-line arguments.
This clarification may resolve confusion from the documentation and aligns it with actual runtime behavior.
Activity
[-]Clarify process.argv[1] behavior for -e/--eval[/-][+]doc: clarify process.argv[1] behavior for -e/--eval[/+]doc: clarify process.argv[1] behavior for -e/--eval
doc: clarify process.argv[1] behavior for -e/--eval
doc: clarify process.argv[1] behavior for -e/--eval
doc: clarify process.argv[1] behavior for -e/--eval
doc: clarify process.argv[1] behavior for -e/--eval
doc: clarify process.argv[1] behavior for -e/--eval
doc: clarify process.argv[1] behavior for -e/--eval
doc: clarify process.argv[1] behavior for -e/--eval
doc: clarify process.argv[1] behavior for -e/--eval