From 8f76a97329d195dc92cf1cd550bbbd92e1e1dc27 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Thu, 29 Oct 2020 15:42:46 -0700 Subject: [PATCH] node-windows can't be loaded detection. --- meshcentral.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/meshcentral.js b/meshcentral.js index 78d5a99a..9bba575f 100644 --- a/meshcentral.js +++ b/meshcentral.js @@ -2782,7 +2782,11 @@ function mainStart() { if (config.settings.heapdump === true) { modules.push('heapdump'); } // Install any missing modules and launch the server - InstallModules(modules, function () { meshserver = CreateMeshCentralServer(config, args); meshserver.Start(); }); + InstallModules(modules, function () { + if (require('os').platform() == 'win32') { try { require('node-windows'); } catch (ex) { console.log("Module node-windows can't be loaded. Restart MeshCentral."); process.exit(); return; } } + meshserver = CreateMeshCentralServer(config, args); + meshserver.Start(); + }); // On exit, also terminate the child process if applicable process.on('exit', function () { if (childProcess) { childProcess.kill(); childProcess = null; } });