How can my node.js code see if it's running under official nodejs, iojs, jxcore, or node-chakracore?

删除回忆录丶 提交于 2019-12-02 07:11:13

问题


There are now several forks of nodejs for various reasons.

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

The forks I am aware of are:

  • The official nodejs release
  • iojs - I guess it's now deprecated since it's rejoined the official nodejs, but it's still of interest
  • JXcore - a fork that supports multiple CPUs/core; multiple JS engines including V8, Mozilla's SpiderMonkey, and Microsoft's ChakraCore; and packaging of js apps so npm doesn't need to be used by users of the apps
  • Microsoft's fork of nodejs using their Edge browser's ChakraCore JS engine via a V8-compatibility shim

(I've also asked a companion question about detecting which JS engine is being used. This question is only about detecting which fork is being used.)


回答1:


NodeJS and iojs can be probably checked by process.release :

name: a string with a value that will always be 'node' for Node.js. For legacy io.js releases, this will be 'io.js'.

As for JXcore you can use either process.jxversion or typeof jxcore !== 'undefined'



来源:https://stackoverflow.com/questions/35037072/how-can-my-node-js-code-see-if-its-running-under-official-nodejs-iojs-jxcore

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