-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
process.argv[0] contains full node.exe path on Windows, docs say it must be just "node" #7434
Comments
The docs are arguably not entirely correct. It will be the node binary, wherever that is. (Including the path.) |
More specifically, how you invoked the node binary. |
I started
|
There’s this line which will always set |
I am up for taking this up. |
The |
@cjihrig Why did the behavior change since perhaps two years ago? I remember clearly that a while ago it was |
#1194 was the PR that changed this for Windows. |
I honestly don't recall. |
The current documentation states that if run something like node app.js then in our process.argv array first elements is node, but actually its process.execPath not node as documentation currently suggests This commit fixes this documentation bug. Fixes : nodejs#7434 PR-URL: nodejs#7449
At this point, the change has been in a wild long enough that backward compatibility would be hard to achieve. |
Reviewed by four contributors. That's impressive. |
@Dmitry-Me I’m not a hundred percent sure what you’re trying to say. Documenting the current behaviour is definitely the right thing to do, independently of whether a change to the actual logic should be made or not. The reviews concerned the correctness of the docs change and I wouldn’t take them to make any statement on what the behaviour should be. I won’t keep you from reopening this issue and making convincing points as to why the behaviour should be changed back, but keep a few things in mind:
|
@addaleax I'm suprised to see so many contributors signing off a commit. It usually takes up to two contributors (elsewhere). I won't make any conclusions. |
@Dmitry-Me I think it’s just that there is a tendency for small changes that are easy to review to gain more reviewers, that’s all. :) |
The current documentation states that if run something like `node app.js` then in our process.argv array first elements is `node`, but actually it's `process.execPath` not `node` as documentation currently suggests. Fixes: #7434 PR-URL: #7449 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
For historical and other reasons, node overwrites `argv[0]` on startup. See - 2c6f79c, - nodejs#7434 - nodejs#7449 - nodejs#7696 For cases where it may be useful, save the original value of `argv[0]` in `process.argv0`
For historical and other reasons, node overwrites `argv[0]` on startup. See - 2c6f79c, - #7434 - #7449 - #7696 For cases where it may be useful, save the original value of `argv[0]` in `process.argv0` PR-URL: #7696 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
For historical and other reasons, node overwrites `argv[0]` on startup. See - 2c6f79c, - #7434 - #7449 - #7696 For cases where it may be useful, save the original value of `argv[0]` in `process.argv0` PR-URL: #7696 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Documentation https://nodejs.org/api/process.html#process_process_argv says
process.argv[0]
must benode
but I run this code on Windowsand it outputs this
which kind of isn't the same as
node
. It wasnode
on some earlier versions - perhaps a couple years ago.Here's how I run my code: I started
cmd.exe
,cd
d intoC:\Program Files (x86)\nodejs
, so it's now the current path and I runThe text was updated successfully, but these errors were encountered: