Install Ruby and Node.js modernly

Hello ! 😉

Today we’ll take a little about Ruby and Node.js installation. As the most of programs, you have the habit to install a software by a .exe /.msi for Microsoft Windows, a .dmg for MacOS and lot of methods for Linux (Mainly using your favorite package manager). As usual it is how you do.

What is wrong with downloading binaries ?

Downloading binaries is a cool fact for software you use. You are using the last version and when an update comes, you just update your software (For best of them, it updates automatically 😛). You are always up-to-date. You installed Java for playing you favorite building game (Minecraft ?). You want the last version, the last patch and game update. You are an user.

However, trouble begins when you want to use a specific version or using several. You have installed the last version of Node.js on your Windows computer and you want to launch a project that does not run on your version. How can you launch it ? You have to uninstall Node.js from your computer and install the asked version. Yeah, really.

This problem does not exist for software you are using (even Node.js or Java) but you discover it when you are making (mind developing here). You are making several projects with different version of your software, you are developing a project with a lot of dependancies that you can’t upgrade. You NEED own several version on your computer. For switching versions. For easily choosing the specific version you want to use.

Using version manager

To fix theses issues, it exists softwares that are managers of your version. We use NVM for Node.js and RVM for Ruby. It allows you to install version as many as you want, use and switching between. Let’s take a look about using them !

Node Version Manager

Downloading nvm

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash

Ruby Version Manager

# Add GPG keys
gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
# Install rvm
curl -sSL https://get.rvm.io | bash -s stable
# Handle rvm error
#
# rvm will throw an error because it needs command to be executed as a "login shell"
# to fix that, follow theses instructions : 
https://stackoverflow.com/questions/23963018/rvm-is-not-a-function-selecting-rubies-with-rvm-use-will-not-work
# Install ruby
rvm install ruby-head
# Use installed version
rvm --default use ruby-2.6.3

Install Node.js on ubuntu

sudo apt-get install curl
curl -sL https://deb.nodesource.com/setup_15.x | sudo -E bash -