diff --git a/setup.js b/setup.js index 562de82c3..622a6bdb0 100644 --- a/setup.js +++ b/setup.js @@ -1,4 +1,5 @@ const path = require("path"); +const fs = require("fs"); const process = require("process"); const { exec } = require("child_process"); const systemCheck = require('./Launch-Scripts/system-check') @@ -76,21 +77,24 @@ for (let dir of nodeModulesDirs) { removeCommand = "echo Removing old Node_Modules at "+ dir + " & rm -rf node_modules/"; } - exec( removeCommand, - { - cwd: dir - }, - function ( error, stdout ){ - if (error) { + let node_dir = path.join(dir, "node_modules") + if (fs.existsSync(node_dir)) { + exec( removeCommand, + { + cwd: dir + }, + function ( error, stdout ){ + if (error) { + console.log(''); + console.log("There was an error installing some dependencies error: "); + console.log(''); + console.log( error ); + return; + } console.log(''); - console.log("There was an error installing some dependencies error: "); - console.log(''); - console.log( error ); - return; - } - console.log(''); - console.log( stdout ); - }); + console.log( stdout ); + }); + } }; // Install Node_Modules to Main Superalgos Directory @@ -132,4 +136,4 @@ function tfjsWinInstall() { console.log("\n1.) Reinstall node.js from https://nodejs.org/en/download/ @Version 14.17.5 or higher.\nDuring installation, when you arrive at the 'Tools for Native Modules' screen you need to select the box to:\n\t'Automatically install the necessary tools...Chocolatey...'"); console.log("Doing this will cause a pop-up script in a new window which will install many npm/node tools and dependencies for use within the WinOS ecosystem."); console.log("2.) When the installations finally complete you need to navigate back to your Superalgos directory and run `node setup` again.\n"); -} \ No newline at end of file +}