How to detect from nodejs running a javascript engine?

Now there are several nodejs forks, and some of them support JavaScript engines other than the Google V8 engine.

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

The engines that I know of are as follows:

  • Google V8 The only engine supported by official node.js and iojs . One of the engines supported by JXcore .
  • Mozilla SpiderMonkey . One of the engines supported by JXcore .
  • Microsoft ChakraCore The engine is supported by Microsoft's node.js port and is apparently one of the engines supported by JXcore , although I still do not work.

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

+5
spidermonkey javascript-engine chakra jxcore
source share
1 answer

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

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.

+7
source share

All Articles