How do I get the nodejs version inside a nodejs program?

旧城冷巷雨未停 提交于 2020-01-03 10:59:09

问题


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?

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.


回答1:


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

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


来源:https://stackoverflow.com/questions/29811562/how-do-i-get-the-nodejs-version-inside-a-nodejs-program

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!