问题
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