Node.js version on the command line? (not the REPL)

后端 未结 13 935
不思量自难忘°
不思量自难忘° 2020-12-07 08:01

I want to get the version of Node.js on the command line. I\'m expecting to run a command like:

node -version

but that doesn\'t work. Does

相关标签:
13条回答
  • 2020-12-07 08:37

    find the installed node version.

    $ node --version
    

    or

     $ node -v
    

    And if you want more information about installed node(i.e. node version,v8 version,platform,env variables info etc.)

    then just do this.

    $ node
    > process
      process {
      title: 'node',
      version: 'v6.6.0',
      moduleLoadList: 
       [ 'Binding contextify',
         'Binding natives',
         'NativeModule events',
         'NativeModule util',
         'Binding uv',
         'NativeModule buffer',
         'Binding buffer',
         'Binding util',
         ...
    

    where The process object is a global that provides information about, and control over, the current Node.js process.

    0 讨论(0)
  • 2020-12-07 08:37

    Just type npm version in your command line and it will display all the version details about node, npm, v8 engine etc.

    0 讨论(0)
  • 2020-12-07 08:37

    You can simply do

    node --version
    

    or short form would also do

    node -v
    

    If above commands does not work, you have done something wrong in installation, reinstall the node.js and try.

    0 讨论(0)
  • 2020-12-07 08:41

    If you're referring to the shell command line, either of the following will work:

    node -v
    
    node --version
    

    Just typing node version will cause node.js to attempt loading a module named version, which doesn't exist unless you like working with confusing module names.

    0 讨论(0)
  • 2020-12-07 08:45

    Repl Command to find the Nodejs Version

    $node
    >process.version
    `v8.x`
    
    0 讨论(0)
  • 2020-12-07 08:48

    One cool tip if you are using the Atom editor.

    $ apm -v
    apm  1.12.5
    npm  3.10.5
    node 4.4.5
    python 2.7.12
    git 2.7.4
    

    It will return you not only the node version but also few other things.

    0 讨论(0)
提交回复
热议问题