如何在Node.js程序中获取Node.js版本? [英] How do I get the nodejs version inside a nodejs program?

查看:1238
本文介绍了如何在Node.js程序中获取Node.js版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

debugger for nodejs 中,有一条命令可以显示V8版本和调试程序包版本.如何获得nodejs版本?

In a debugger for nodejs, there is a command to show the V8 version and the debugger package version. How can I get the nodejs version?

我想我基本上可以运行命令node --versionnodejs --version,但是我希望有一种无需运行外部shell命令的方法.这不仅较慢,而且根据路径,可能会给出不同的答案.

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.

推荐答案

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

Use process.version to get the version of Node that is running:

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

这篇关于如何在Node.js程序中获取Node.js版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆