Skip to content

process.argv[0] contains full node.exe path on Windows, docs say it must be just "node" #7434

Description

@Dmitry-Me
  • Version: 4.4.6.0
  • Platform: Windows 7 Enterprise SP1
  • Subsystem: no idea

Documentation https://nodejs.org/api/process.html#process_process_argv says process.argv[0] must be node but I run this code on Windows

console.log('argv[0]: ' + process.argv[0]);

and it outputs this

argv[0]: C:\Program Files (x86)\nodejs\node.exe

which kind of isn't the same as node. It was node on some earlier versions - perhaps a couple years ago.

Here's how I run my code: I started cmd.exe, cdd into C:\Program Files (x86)\nodejs, so it's now the current path and I run

node fullPathToJsFile

Activity

  1. Fishrock123 commented on Jun 27, 2016

    @Fishrock123
    Contributor
    ./node -p 'process.argv[0]'
    /Users/Jeremiah/Documents/node/out/Release/node
    

    The docs are arguably not entirely correct. It will be the node binary, wherever that is. (Including the path.)

  2. added
    questionIssues asking questions about Node.js.
    docIssues and PRs related to Node.js documentation.
    and removed
    questionIssues asking questions about Node.js.
    on Jun 27, 2016
  3. Fishrock123 commented on Jun 27, 2016

    @Fishrock123
    Contributor

    More specifically, how you invoked the node binary. node ... will have node but ./ will append the path to the local node.

  4. Dmitry-Me commented on Jun 27, 2016

    @Dmitry-Me
    Author

    I started cmd, cdd into C:\Program Files (x86)\nodejs, so it's now the current path. I run

     node fullPathToJsFile
    
  5. added
    processIssues and PRs related to the process subsystem.
    on Jun 27, 2016
  6. addaleax commented on Jun 27, 2016

    @addaleax
    Member

    There’s this line which will always set process.argv[0] to process.execPath, so usually it won’t matter how node was invoked.

  7. tarungarg546 commented on Jun 27, 2016

    @tarungarg546
    Contributor

    I am up for taking this up.
    What needs to done exactly modifying docs?

  8. cjihrig commented on Jun 27, 2016

    @cjihrig
    Contributor

    The process.argv docs should be updated to say that the first element will be process.execPath. It would probably be good to link there too.

  9. Dmitry-Me commented on Jun 27, 2016

    @Dmitry-Me
    Author

    @cjihrig Why did the behavior change since perhaps two years ago? I remember clearly that a while ago it was node, not full path.

  10. addaleax commented on Jun 27, 2016

    @addaleax
    Member

    #1194 was the PR that changed this for Windows.

  11. cjihrig commented on Jun 27, 2016

    @cjihrig
    Contributor

    I honestly don't recall.

  12. 9 remaining items

  13. Dmitry-Me commented on Jul 4, 2016

    @Dmitry-Me
    Author

    @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.

  14. addaleax commented on Jul 4, 2016

    @addaleax
    Member

    @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. :)

  15. added a commit that references this issue on Aug 8, 2016
  16. added a commit that references this issue on Aug 10, 2016
  17. added
    docIssues and PRs related to Node.js documentation.
    and removed
    docIssues and PRs related to Node.js documentation.
    on Dec 1, 2016
  18. added a commit that references this issue on Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to Node.js documentation.processIssues and PRs related to the process subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions