Install Node.js
The Node.js/NPM versions in the Linux package manager are usually pretty old, so it’s best to manually install a newer version.
First, go to https://nodejs.org and download either the LTS or Current binary archive, depending on your needs.
Then (update the VERSION and DISTRO values accordingly):
- Unzip the binary archive to
/usr/local/lib/nodejs
.
VERSION=v10.15.0
DISTRO=linux-x64
sudo mkdir -p /usr/local/lib/nodejs
sudo tar -xJvf node-$VERSION-$DISTRO.tar.xz -C /usr/local/lib/nodejs
- Add the following at the end of
~/.profile
:
# Nodejs
VERSION=v10.15.0
DISTRO=linux-x64
export PATH=/usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin:$PATH
- Refresh your profile:
. ~/.profile
- Test the installation:
node -v
npm version
npx -v
Source: https://github.com/nodejs/help/wiki/Installation#how-to-install-nodejs-via-binary-archive-on-linux