Skip to content

Instantly share code, notes, and snippets.

@im-coder-lg
Last active September 6, 2021 08:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save im-coder-lg/a2b7c63a513d746b18f9e0f45bd4dd84 to your computer and use it in GitHub Desktop.
Save im-coder-lg/a2b7c63a513d746b18f9e0f45bd4dd84 to your computer and use it in GitHub Desktop.
Install Node JS LTS/Latest via a simple shell script.

About this gist

Ladies and gentlemen, this is a work in progress.

Only for Linux. Mainly Debian-based distros. I'm sorry. I will add support for RPM and DNF-based distros soon. Open issues here

#!/bin/bash
echo "What version of Node JS do you want? The LTS or the latest release?"
echo "Respond with LTS or latest(case sensitive)"
read versionofnode
if [ "$versionofnode" = "LTS" ]; then
sudo apt-get install curl software-properties-common
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -
sudo apt install nodejs
node -v && npm -v
fi
if [ "$versionofnode" = "latest" ]; then
sudo apt-get install curl software-properties-common
curl -sL https://deb.nodesource.com/setup_16.x | sudo bash -
sudo apt install nodejs
node -v && npm -v
fi
# wip
echo "Node JS is installed. Do you want to test it?"
echo "Respond with yes or no(case sensitive)"
read test
if [ "$test" = "yes" ]; then
mkdir tmp
cd tmp
wget https://raw.githubusercontent.com/im-coder-lg/special-projects/master/install-nodejs/server-test.js --no-check-certificate
node server-test.js
fi
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(3000, "127.0.0.1");
console.log('Server running at http://127.0.0.1:3000/');
@im-coder-lg
Copy link
Author

im-coder-lg commented Sep 6, 2021

chore:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment