命令行上的Node.js版本? (不是REPL)

本文翻译自: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 --versionnode -v

npm : npm

npm --version or npm -v npm --versionnpm -v

V8 engine version : V8发动机版本

node -p process.versions.v8
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章