检查node.js版本_如何在运行时检查当前的Node.js版本

检查node.js版本

Run process.version:

运行process.version

The version property of the process object returns a string with the current Node.js version.

process对象的version属性返回具有当前Node.js版本的字符串。

In the browser the process object is not defined, so you will get a ReferenceError:

在浏览器中,未定义process对象,因此您将获得ReferenceError:

Another way is to reference process.versions (plural):

另一种方法是引用process.versions (复数):

This returns an object that contains various properties referencing each component’s version.

这将返回一个对象,其中包含引用每个组件版本的各种属性。

To get the major version (in this example 12) you can use

要获取主要版本(在本示例中为12 ),您可以使用

process.versions.node.split('.')[0]

翻译自: https://flaviocopes.com/node-version-runtime/

检查node.js版本

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值