Updating NodeJS - misael-diaz/react-app-twitter GitHub Wiki

If you wish to install the latest version of NodeJS system wide you can follow the steps given in this tutorial; if you do not have administrator privileges, continue reading to proceed with a local installation.

Install Node's version manager locally:

npm install --save n

Prepend the PATH with the installation directory so that the latest version of Node's version manager gets executed when you invoke it on the terminal:

export PATH="$PWD/node_modules/n/bin":"$PATH"

Create an installation directory for the latest version of NodeJS at the same level as the node_modules directory:

mkdir -p node/latest

Export N_PREFIX for a local installation of NodeJS:

export N_PREFIX="$PWD/node/latest"

And install the latest version of NodeJS by executing:

n latest

Prepend the PATH so that the locally installed version of NodeJS gets executed when you invoke it on the terminal:

export PATH="$PWD/node/latest/bin":"$PATH"

At the time of writing the latest version of NodeJS was

node --version
v19.8.1

and the latest version of its package manager was

npm --version
9.5.1

Cheers!