diff --git a/deploy.js b/deploy.js index 54a3d89..fd99ee2 100644 --- a/deploy.js +++ b/deploy.js @@ -170,12 +170,24 @@ if (needsNode || !hasAcceptableNodeVersion) { : "Node.js is missing on the host machine. Installing" ); + if (!hasAcceptableNodeVersion) { + await ssh.execCommand(`sudo apt remove node && sudo apt autoremove`); + } await ssh.execCommand(`cd ~`); await ssh.execCommand(`curl -sL https://deb.nodesource.com/setup_${PREFERRED_NODE_VERSION} -o nodesource_setup.sh`); await ssh.execCommand(`sudo bash nodesource_setup.sh`); await ssh.execCommand(`sudo apt install nodejs -y`); await ssh.execCommand(`rm nodesource_setup.sh`); - console.log("Node.js successfully installed!"); + + // Re-check the installed Node version and ensure that it is in fact the intended one + const nodeVersionNow = (await ssh.execCommand("node -v")).stdout.slice(1); + if (!satisfies(nodeVersionNow, PREFERRED_NODE_VERSION)) { + throw new ReferenceError(`Node v${PREFERRED_NODE_VERSION} could not be installed.`); + } else { + console.log("Node.js successfully installed!"); + } + + } else { console.log("Node.js is already supported"); } diff --git a/package.json b/package.json index 67ce2af..51c44c8 100644 --- a/package.json +++ b/package.json @@ -116,7 +116,7 @@ "node.parentelement": "1.0.2", "perfnow": "0.2.0", "performance-now": "2.1.0", - "pm2": "5.2.0", + "pm2": "5.2.2", "polyfill-library": "3.108.0", "proxy-polyfill": "0.3.2", "regenerator-runtime": "0.13.11",