Installing Node.js on Ubuntu 23.10

Hello,
In this week’s feature highlight, we look at How to Install Node.js on Ubuntu 23.10

Node.js is an open-source, server-side runtime environment that allows you to run JavaScript on the server. It is designed to be efficient and lightweight and is commonly used to build scalable network applications and web services.

To install Node.js on an Ubuntu 23.10 server, you can follow these steps:

Login to the Ubuntu 23.10 server and update the package repository information.

apt update

Install NVM manager

NVM, which stands for Node Version Manager, is a popular tool for managing multiple versions of Node.js on a single machine. It allows you to switch between different Node.js versions and manage global and project-specific versions with ease.

To install nvm, you can use the following command in your terminal:

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.39.3/install.sh | bash

Output:

root@vps:~# wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.39.3/install.sh | bash
=> Downloading nvm from git to '/root/.nvm'
=> Cloning into '/root/.nvm'...
remote: Enumerating objects: 360, done.
remote: Counting objects: 100% (360/360), done.
remote: Compressing objects: 100% (306/306), done.
remote: Total 360 (delta 41), reused 167 (delta 28), pack-reused 0
Receiving objects: 100% (360/360), 220.29 KiB | 2.16 MiB/s, done.
Resolving deltas: 100% (41/41), done.
* (HEAD detached at FETCH_HEAD)
  master
=> Compressing and cleaning up git repository

=> Appending nvm source string to /root/.bashrc
=> Appending bash_completion source string to /root/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
root@vps:~#

Update your shell ~/.profile by running following command

source ~/.profile

Next, Check the if NVM installed or not by checking for its version.

nvm --version

Output:

root@vps:~# nvm --version
0.39.3
root@vps:~#

List out the all available Node.js versions. you can see all Node.js versions from the first version to the latest version.

nvm ls-remote

Output:

root@vps:~# nvm ls-remote
        v0.1.14
        v0.1.15
        v0.1.16
        v0.1.17
        v0.1.18
        .......
        ......
        .....
        ....
        ...
        ..
        v20.6.1
        v20.7.0
        v20.8.0
        v20.8.1
        v21.0.0
root@vps:~#

To install a specific Node.js version, use the following command. Here, we are installing v21.0.0. If you want to install another version, replacing v21.0.0 with the version number you want:

nvm install 21.0.0

Output:

root@vps:~# nvm install 21.0.0
Downloading and installing node v21.0.0...
Downloading https://nodejs.org/dist/v21.0.0/node-v21.0.0-linux-x64.tar.xz...
############################################################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v21.0.0 (npm v10.2.0)
Creating default alias: default -> 21.0.0 (-> v21.0.0)
root@vps:~#

And check the version of the Node.js once the installation is done.

node -v

Output:

root@vps:~# node -v
v21.0.0
root@vps:~#

Done!

(Visited 246 times, 1 visits today)