如何从nodejs中检测运行在哪个JavaScript引擎上? [英] How to detect from nodejs which JavaScript engine it is running on?

查看:233
本文介绍了如何从nodejs中检测运行在哪个JavaScript引擎上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在有几个nodejs的分支,其中有些支持Google的V8引擎以外的JavaScript引擎.

There are now several forks of nodejs and some of them support JavaScript engines other than Google's V8 engine.

要让我的节点代码查看其运行在哪个JS引擎上,目前的最佳方法是什么?

For my node code to see which JS engine it is running under, what is currently the best way?

我知道的引擎是:

  • Google的 V8 -官方 node.js iojs 分支支持的唯一引擎. JXcore 支持的引擎之一.
  • Mozilla的 SpiderMonkey - JXcore 支持的引擎之一.
  • Microsoft的 ChakraCore -由 Microsoft 的node.js端口支持的引擎,显然是 JXcore 所支持的引擎之一还没有那个可以上班.
  • Google's V8 - The only engine supported by the official node.js and the iojs fork. One of the engines supported by JXcore.
  • Mozilla's SpiderMonkey - One of the engines supported by JXcore.
  • Microsoft's ChakraCore - The engine supported by Microsoft's port of node.js and apparently one of the engines supported by JXcore though I haven't got that one to work yet.

(我问了一个有关检测正在使用哪个nodejs分支的单独问题.该问题仅与检测以下问题有关: JS引擎.)

(I've asked a separate question about detecting which fork of nodejs is being used. This question is only about detecting the JS engine.)

推荐答案

process对象包含有关当前正在运行的进程(在本例中为节点)的许多信息.

The process object contains a lot of information about the currently running process (in this case, node).

我的process.versions包含V8的当前版本:

My process.versions for example, contains the current version of V8:

process: {
    versions: {
        http_parser: '2.5.0',
        node: '4.2.4',
        v8: '4.5.103.35',
        uv: '1.7.5',
        zlib: '1.2.8',
        ares: '1.10.1-DEV',
        icu: '56.1',
        modules: '46',
        openssl: '1.0.2e'
    }
}

您应该能够查询该对象并确定当前引擎.

You should be able to query this object and determine the current engine.

这篇关于如何从nodejs中检测运行在哪个JavaScript引擎上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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