MdFarzan
MdFarzan

Reputation: 390

Unable to install nodejs in ubuntu v-20.04.1

I am trying to install nodejs version 14.15.4 using this command-

apt install nodejs=14.15.4

But I am getting this error- E: Version '14.15.4' for 'nodejs' was not found

Which mistake I am doing in this command?

Or any better way to install it?

Upvotes: 5

Views: 8933

Answers (2)

fcva
fcva

Reputation: 449

To install Node.js v14.x in Ubuntu 20.04

curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash - 
sudo apt-get install -y nodejs

Upvotes: 1

PiggyPlex
PiggyPlex

Reputation: 703

The easiest way (from my experience) has always been using node version manager, as it allows you to switch between node.js versions easily. To begin, make sure you're up to date: sudo apt update.

Install NVM first using either cURL or wget using one of the following:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash

We then need to load NVM, which can be done with:

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

Then, use nvm install 14.15.4.

Upvotes: 6

Related Questions