Installation and updating of Node.js can be sometimes little complicated or annoying, there can be issues with version in your distribution’s repository or after update of npm will start showing weird errors.
The solution is to use Node Version Manager.
We will download and run nvm install shell script (check this link if code bellow is outdated):
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
or with wget
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
to download, compile, and install the latest release of node, do this:
nvm install node # "node" is an alias for the latest version
to install a specific version of node:
nvm install 14.7.0 # or 16.3.0, 12.22.1, etc
to update node to latest version run:
nvm install node --reinstall-packages-from=node
to update Stable (LTS) version: (if currently in use):
nvm install "lts/*" --reinstall-packages-from="$(nvm current)"