本文翻譯自:Node.js version on the command line? (not the REPL)
I want to get the version of node.js on the command line - I'm expecting to run a command like: 我想在命令行上獲取node.js的版本 - 我希望運行如下命令:
node -version
but that doesn't work. 但這不起作用。 Does anybody know what the command line would be? 有人知道命令行是什麼嗎? (ie not the REPL) (即不是REPL)
#1樓
參考:https://stackoom.com/question/10TAd/命令行上的Node-js版本-不是REPL
#2樓
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. 如果node -v
不起作用,但是nodejs -v
沒有,那麼你的系統上沒有設置好的東西。 See this other question for ways to fix it. 請參閱此其他問題以瞭解解決方法。
#3樓
If you're referring to the shell command line, either of the following will work: 如果您指的是shell命令行,則以下任一操作都可以:
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. 只鍵入node version
將導致node.js嘗試加載名爲version的模塊,除非您喜歡使用令人困惑的模塊名稱,否則該模塊不存在。
#4樓
Try nodejs
instead of just node
嘗試使用nodejs
而不僅僅是node
$ nodejs -v
v0.10.25
#5樓
By default node package is nodejs, so use 默認節點包是nodejs,所以使用
$ 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
#6樓
Node : 節點 :
node --version
or node -v
node --version
或node -v
npm : npm :
npm --version
or npm -v
npm --version
或npm -v
V8 engine version : V8發動機版本 :
node -p process.versions.v8