Forem Creators and Builders ๐ŸŒฑ

Cover image for Installing Forem on Ubuntu 18.04 (Part 2 - NVM, Node & Yarn)
Dawood Khan Masood
Dawood Khan Masood

Posted on • Edited on • Originally published at hackhex.com

Installing Forem on Ubuntu 18.04 (Part 2 - NVM, Node & Yarn)

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.

No one likes Alt Text!

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]
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Run the script with bash:

$ bash install_nvm.sh
Enter fullscreen mode Exit fullscreen mode

Source the ~/.profile file so that your current session knows about the changes:

$ source ~/.profile
Enter fullscreen mode Exit fullscreen mode

To check which version of NVM is installed, type:

$ nvm --version
Enter fullscreen mode Exit fullscreen mode

The output will be something like:

0.35.3
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

You can tell nvm to use the version you just downloaded by typing:

$ nvm use 12.18.3
Enter fullscreen mode Exit fullscreen mode

To check if Node is installed, type:

$ node -v 
Enter fullscreen mode Exit fullscreen mode

The output will be something like this:

v12.18.3
Enter fullscreen mode Exit fullscreen mode

Installing Yarn using NPM

The final step is to install Yarn by running the following command:

$ npm install -g yarn
Enter fullscreen mode Exit fullscreen mode

To check if Yarn is installed successfully, type:

$ yarn --version
Enter fullscreen mode Exit fullscreen mode

The output will be something like this:

1.22.4
Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
ben profile image
Ben Halpern

Great guide

Collapse
 
avalerionv profile image
Dawood Khan Masood

Thank you, Ben. :)