简体   繁体   English

如何在nodejs程序中获取nodejs版本?

[英]How do I get the nodejs version inside a nodejs program?

In a debugger for nodejs , there is a command to show the V8 version and the debugger package version. nodejs调试器中 ,有一个显示V8版本和调试器包版本的命令。 How can I get the nodejs version? 我如何获得nodejs版本?

I imagine I can basically run a command node --version or nodejs --version , but I'm hoping there a is way to do with without running an external shell command – which is not only slower but, depending on paths, might give a different answer. 我想我基本上可以运行一个命令node --versionnodejs --version ,但我希望有一种方法可以不运行外部shell命令 - 这不仅速度较慢,而且取决于路径,可能会给出一个不同的答案。

使用process.version获取正在运行的Node版本:

console.log('Node version is: ' + process.version);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM