Skip to content

Latest commit

 

History

History
106 lines (67 loc) · 4.48 KB

3A1-linux-download-install-nodejs.md

File metadata and controls

106 lines (67 loc) · 4.48 KB

HOME

0) COMMON : INTRODUCTION

1) COMMON : MESSAGE OGS MODERATORS

2) COMMON : GENERATE THE APIKEY

3A) FOR LINUX

3B) FOR WINDOWS

3A1) Download and install nodejs and npm

This tutorial uses Ubuntu 20.04 as an example, but it works the same in any compatible linux distribution.

Install node and npm

To install node.js, apt package manager only provides an old version of nodejs, so the recommended way to install node.js for ubuntu 20.04 and higher is to use nvm (Node Version Manager).

First, download and install the latest version of nvm by downloading and runnning install.sh from nvm's github

For example, as of today:

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

Then finalize the install by updating your shell environment

source ~/.profile

You can check nvm is installed by running nvm -v.

Then, display all available node versions that can be installed by running nvm ls-remote

nvm install 0

In this tutorial i'll be choosing node version 14 because it is the soon to be LTS at the time of writing this tutorial, and it adds support for a recent addition to the javascript language that i want (nullish coalescing)

Generally, unless there is a specific need, it is advised to go either with latest LTS or latest beta version available depending on your needs. You can also check node.js releases status here.

So, scrolling all available versions result all the way down until the bottom...

In this example, i'm running nvm install 14.2.0 (latest node 14 available)

nvm install 1

Finally, we can make sure node and npm were successfully installed by running node -v and npm -v.

How to change node and npm version

You may want to upgrade to a more recent node version, or go do the opposite and test an older version for compatibility or debugging purposes.

To do that, just do nvm install <version_number> to install (if not already installed) and switch to using the specified <version_number>

For example, to use node 14.0.0 instead of 14.2.0 i have to run nvm install 14.0.0

To revert it back, just do the opposite, for example nvm install 14.2.0 to use node version 14.2.0 again)

nvm node upgrade 0

How to upgrade nvm

It is a good idea to upgrade nvm to latest available version whenever you want to use it (modify node version for example, as seen above)

For example, at the time i am updating this tutorial, nvm latest version is not anymore 0.33.8 but is now 0.35.2

To do that, just run the nvm install again as we saw at the begining:

  • install latest install.sh from nvm's github
  • update shell environment with source ~/.profile

nvm upgrade 0

Next page ->