如何使用 PhantomJS 验证机器配置

How to verify the machine configuration using PhantomJS

我的本地机器上的 karma-phantom-launcher 插件正在使用 PhantomJS。我想获取机器配置是32位还是64位。

类似于我们可以用 node.js 做的事情,即在 运行 节点之后我们可以简单地键入 process.arch获取节点为运行.

的机器配置

稍微研究一下文档就会发现您可以使用 system module 来执行此操作:

var system = require('system');
console.log(system.os.architecture);

以下代码将满足您的要求

var system = require('system');
var os = system.os;
console.log(os.architecture);  // '32bit'
console.log(os.name);  // 'windows'
console.log(os.version);  // '7'

您将在控制台中获得信息....