Install Node and NPM

In this section, we will introduce two options to install node and npm that are required to run LLM Whisper Web for Speech-to-text.

From Default Repositories

Ubuntu 20.04 contains a version of Node.js in its default repositories that can be used to provide a consistent experience across multiple systems. 

Warning: the version of Node.js included with Ubuntu 20.04, version 10.19, is now unsupported and unmaintained. You should not use this version in production, and should refer to one of the other sections in this tutorial to install a more recent version of Node.

To get this version, you can use the apt package manager. Refresh your local package index first:

sudo apt update

Then install Node.js:

sudo apt install nodejs

Check that the install was successful by querying node for its version number:

node -v
output
v10.19.0

If the package in the repositories suits your needs, this is all you need to do to get set up with Node.js. In most cases, you’ll also want to also install npm, the Node.js package manager. You can do this by installing the npm package with apt:

sudo apt install npm

This allows you to install modules and packages to use with Node.js.

At this point, you have successfully installed Node.js and npm using apt and the default Ubuntu software repositories. The next section will show how to use an alternate repository to install different versions of Node.js.

Node Version Manager

Another way of installing Node.js that is particularly flexible is to use nvm, the Node Version Manager. This piece of software allows you to install and maintain many different independent versions of Node.js, and their associated Node packages, at the same time.

To install NVM on your Ubuntu 20.04 machine, visit the project’s GitHub page. Copy the curl command from the README file that displays on the main page. This will get you the most recent version of the installation script.

Before piping the command through to bash, it is always a good idea to audit the script to make sure it isn’t doing anything you don’t agree with. You can do that by removing the | bash segment at the end of the curl command:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh 

Review the script and make sure you are comfortable with the changes it is making. When you are satisfied, run the command again with | bash appended at the end. The URL you use will change depending on the latest version of nvm, but as of right now, the script can be downloaded and executed with the following:

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

This will install the nvm script to your user account. To use it, you must first source your .bashrc file:

source ~/.bashrc

Now, you can ask NVM which versions of Node are available:

nvm list-remote
output:
 v20.12.2   (LTS: Iron)
       v20.13.0   (LTS: Iron)
       v20.13.1   (LTS: Iron)
       v20.14.0   (LTS: Iron)
       v20.15.0   (LTS: Iron)
       v20.15.1   (LTS: Iron)
       v20.16.0   (LTS: Iron)
->     v20.17.0   (Latest LTS: Iron)
        v21.0.0
        v21.1.0
        v21.2.0
        v21.3.0
        v21.4.0
        v21.5.0

It’s a very long list. You can install a version of Node by writing in any of the release versions listed. For instance, to get version v14.10.0, you can run:

nvm install v14.21.3

When you look the remote versions, there is an alias, You can install a release based on the alias as well. For instance, to install the latest long-term support version, Iron, run the following:

 nvm install v20.17.0
or
 nvm install lts/Iron

You can view the different versions you have installed by listing them:

nvm list
output:
         v14.21.3
->     v20.17.0
         system
default -> v20.17.0
node -> stable (-> v20.17.0) (default)
stable -> 20.17 (-> v20.17.0) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/iron (-> v20.17.0)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.3 (-> N/A)
lts/gallium -> v16.20.2 (-> N/A)
lts/hydrogen -> v18.20.4 (-> N/A)
lts/iron -> v20.17.0

You can switch between installed versions with nvm use:

nvm use v14.21.3
Output
Now using node v14.21.3 (npm v6.14.18)
```

You can verify that the installation was successful using the same technique from the other sections:

```command
node -v
Output
v14.21.3