How to install nodejs on ubuntu?

by aliya.yundt , in category: Installation & Upgrades , 2 years ago

How to install nodejs on ubuntu?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by margarett , 2 years ago

@aliya.yundt 

To install Node.js on Ubuntu, follow these steps:

  1. Open a terminal window.
  2. Update the package manager index by running the following command:sudo apt update
  3. Install the latest stable version of Node.js by running the following command:sudo apt install nodejs
  4. Verify the installation by running the following command, which will print the version number of Node.js:nodejs -v


Alternatively, you can install the latest version of Node.js by using a package manager called nvm (Node Version Manager). To install nvm, follow these steps:

  1. Open a terminal window.
  2. Download the nvm installation script from the project's GitHub page by running the following command:curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash This will download the installation script and run it.
  3. Close and reopen the terminal window to activate nvm.
  4. Install the latest version of Node.js by running the following command:nvm install node
  5. Verify the installation by running the following command, which will print the version number of Node.js:node -v


Note: These instructions assume that you are using a version of Ubuntu that uses the APT package manager. If you are using a different version of Linux or a different package manager, the steps to install Node.js may be different.

by emilia_hackett , 2 years ago

@aliya.yundt 

To install Node.js on Ubuntu, follow these steps:

  1. First, update the package manager's list of available packages:
1
sudo apt update


  1. Next, install the Node.js package:
1
sudo apt install nodejs


  1. Verify that the installation was successful by checking the version of Node.js that was installed:
1
nodejs --version


This should print the version number of Node.js that was installed.


Alternatively, you can install Node.js using the Node Version Manager (nvm). nvm allows you to install and manage multiple versions of Node.js on your system. To install nvm, follow these steps:

  1. Download the nvm installation script from the nvm GitHub page:
1
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash


  1. Activate nvm by adding the following line to your .bashrc or .bash_profile file:
1
2
3
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"  # This loads nvm bash_completion


  1. Reload the configuration file:
1
source ~/.bashrc


  1. Check that nvm was installed correctly:
1
nvm --version


  1. To install the latest stable version of Node.js using nvm, run:
1
nvm install node


  1. To use the version of Node.js that you just installed, run:
1
nvm use node


You can also specify a specific version of Node.js to install, such as nvm install 12.18.3 to install version 12.18.3. To see a list of available versions, run nvm ls-remote.