If there is anything you would like me to change, please comment. This section of the guide assumes you have already installed Ruby on Rails from the previous article.
Prerequisites
You should have a non-root user account with sudo privileges set up on your system. You can do so by running the following command:
$ sudo usermod -aG sudo [YOUR_USERNAME]
Replace "[YOUR_USERNAME]" with the user you are currently logged in as. This command adds your user to the sudo group.
Installing NVM
An alternative to installing Node.js with apt is to use a tool called nvm, which stands for โNode.js Version Managerโ. You can install multiple self-contained versions of Node.js without affecting the entire system.
Use curl to download the nvm installation script from the projectโs GitHub page:
$ curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.35.3/install.sh -o install_nvm.sh
Run the script with bash:
$ bash install_nvm.sh
Source the ~/.profile file so that your current session knows about the changes:
$ source ~/.profile
To check which version of NVM is installed, type:
$ nvm --version
The output will be something like:
0.35.3
According to Forem's documentation for Linux, it is recommended that you install either LTS or current version of Node. The latest LTS version is v12.18.3. You can install that by typing:
$ nvm install 12.18.3
You can tell nvm to use the version you just downloaded by typing:
$ nvm use 12.18.3
To check if Node is installed, type:
$ node -v
The output will be something like this:
v12.18.3
Installing Yarn using NPM
The final step is to install Yarn by running the following command:
$ npm install -g yarn
To check if Yarn is installed successfully, type:
$ yarn --version
The output will be something like this:
1.22.4
Top comments (2)
Great guide
Thank you, Ben. :)