Se haría uso de exec.
Para apagar el PC:
// shutdown.js
// Require child_process
var exec = require('child_process').exec;
// Create shutdown function
function shutdown(callback){
exec('shutdown now', function(error, stdout, stderr){ callback(stdout); });
}
// Reboot computer
shutdown(function(output){
console.log(output);
});
Para reiniciar:
// reboot.js
// Require child_process
var exec = require('child_process').exec;
// Create shutdown function
function shutdown(callback){
exec('shutdown -r now', function(error, stdout, stderr){ callback(stdout); });
}
// Reboot computer
shutdown(function(output){
console.log(output);
});
Fuente: https://ourcodeworld.com/articles/read/411/how-to-shutdown-and-reboot-linux-with-node-js
Saludos,