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

2019-01-16 01:23发布

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 anybody know what the command line would be? (ie not the REPL)

10条回答
做自己的国王
2楼-- · 2019-01-16 02:11

By default node package is nodejs, so use

$ nodejs -v

or

$ nodejs --version 

You can make a link using

$ sudo ln -s /usr/bin/nodejs /usr/bin/node

then u can use

$ node --version

or

$ node -v
查看更多
姐就是有狂的资本
3楼-- · 2019-01-16 02:13

If you want to check in command prompt use node -v or node --version

v6.9.5

If u have node.exe then in node you can give.

>process
process {
  title: 'node',
  version: 'v6.9.5',
  .......
查看更多
趁早两清
4楼-- · 2019-01-16 02:14

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.

查看更多
Melony?
5楼-- · 2019-01-16 02:17

The command line for that is:

node -v

Or

node --version

Note:

If node -v doesn't work, but nodejs -v does, then something's not set up quite right on your system. See this other question for ways to fix it.

查看更多
登录 后发表回答