Install necessary dependencies:

sudo apt-get install -y python3 g++ make python3-pip

Download Node.js version 20.15.1 source:

wget https://nodejs.org/dist/v20.5.1/node-v20.15.1.tar.gz

Extract the Node.js archive in the current directory with the following command:

tar -xvzf node-v20.15.1.tar.gz

If the path to your build directory contains a space, the build will likely fail.

Then run the following to build Node.js:

sudo apt-get install python3 g++ make python3-pip

Navigate into the directory node-v20.15.1 after extracting the archive.

cd node-v20.15.1

Run the configure script:

./configure

Compile the source code:

make -j4

Install Node.js:

sudo make install