1sudo apt-get install curl
2curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
3sudo apt-get install nodejs
4# Check node version
5node -v
6# v13.9.0
7# Also, check the npm version
8npm -v
9# 6.13.7
1sudo apt-get install curl
2curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
3sudo apt-get install nodejs
4
5node -v #to check if its installed
1# Through nodesource
2curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
3sudo apt install nodejs
1curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
2
3sudo apt install nodejs
4
5node --version
6npm --version
11.Enable the NodeSource repository by running the following curl command as a user with sudo privileges :
2
3$ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
4
5The command will add the NodeSource signing key to your system, create an apt sources repository file, install all necessary packages and refresh the apt cache.
6
7If you need to install another version, for example 14.x, just change setup_12.x with setup_14.x
8
92. Once the NodeSource repository is enabled, install Node.js and npm by typing:
10
11$ sudo apt install nodejs
12
13The nodejs package contains both the node and npm binaries.
14
153. Verify that the Node.js and npm were successfully installed by printing their versions:
16
17$ node --version
18
19v12.16.3
20
21$ npm --version
22
236.14.4
24
25Uninstall Node.js
26
27$ sudo apt remove nodejs npm