为什么Node.js Scaling在Linux上运行,而在Windows上运行?

时间:2018-06-11 15:11:52

标签: node.js linux windows

学习节点并坚持这个例子:

// Adding child_process from the Node build-in Module:
let exec = require("child_process").exec;
// Requesting time:
let child = exec("uptime", function(err, stdout, stderr){
    if (err) {
      console.log("Error: " + stderr);
    } else {
      console.log("Output is: " + stdout);
    }
});
console.log("PID is: " + child.pid);

有人可以解释一下,为什么这段代码在Linux中而不是在Windows中运行。对不起,这可能是一个愚蠢的问题,但我是新手,目前正在学习Node。 附:对不起,如果我的问题不正确,我还是习惯在这里发帖提问。提前谢谢!

1 个答案:

答案 0 :(得分:0)

我认为正常运行时间不是Windows命令。它只适用于Linux 你可以使用

systeminfo | find "Boot Time"

取代正常运行时间。像

exec('systeminfo | find "Boot Time"')