简体   繁体   English

如何验证node.js版本(node -v除外)

[英]How to verify node.js version (other than node -v)

I have this strange issue, where I am using 10th version of node (10.9.0) on a server, but things that should work or be supported in that version, are not. 我有一个奇怪的问题,我在服务器上使用节点的第十版(10.9.0),但在该版本中应该工作或受支持的东西却没有。 For example, according to this table , this version supports Object.values() . 例如,根据此表 ,此版本支持Object.values() On my local node installation - this indeed works, but on server, where I don't have much freedom about what software I am using, it does not. 在我的本地节点上安装-确实可以,但是在服务器上(我对所使用的软件没有太多自由),在服务器上却没有。

Is there any way to truly verify used node version ( node -v shows 10.9.0 as written above)? 有什么方法可以真正验证所使用的节点版本( node -v如上所示显示10.9.0)? Maybe it's only a version of main binary yet all libs it's using are from version 6 (that one is also installed on that server)? 也许它只是主二进制文件的一个版本,但它使用的所有库都是来自版本6(该服务器上也安装了一个库)?

The process object that Node.js exposes has a lot of information including the version. Node.js公开的process对象具有很多信息,包括版本。

console.log(process.version); // v10.9.0

You can find the Node.js process.verison documentation here . 您可以在此处找到Node.js process.verison文档

So within your application you can run that to see if it's truly what you expect. 因此,在您的应用程序中,您可以运行它来查看它是否确实是您所期望的。

You can also try running which node on your server. 您也可以尝试运行服务器上的which node That should print the path it's using to find node. 那应该打印它用来查找节点的路径。 If you have multiple copies or installations of node, it might be using a path that is outdated. 如果您有节点的多个副本或安装,则它可能使用的路径已过时。 Making sure your path is up to date will solve that problem, and which node can help debug that. 确保您的路径是最新的将解决该问题,以及which node可以帮助调试。

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

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