install nodejs version code example

Example 1: linux install node

sudo apt install nodejs

Example 2: how to update node in ubuntu 18.04

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs

Example 3: update node js version ubuntu

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

Example 4: install node js command

# Make a new folder for node
mkdir node
cd node
# Download and unzip node
curl -O https://nodejs.org/dist/v10.15.3/node-v10.15.3-linux-x64.tar.gz
tar -xvzf node-v10.15.3-linux-x64.tar.gz --strip-components=1
# Add node and npm it to PATH (and do so for future sessions too)
export PATH=$HOME/node/bin:$PATH
echo 'export PATH=$HOME/node/bin:$PATH' >> ~/.bashrc

Example 5: linux install node

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -