Ubuntu – Ubuntu / Install NodeJS & npm


I'm trying to install nodejs and npm, however, it fails. This is my terminal:

sudo apt-get install nodejs npm
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
nodejs : Conflicts: npm
E: Unable to correct problems, you have held broken packages.

What to do? I'm kinda lost 🙁

Best Answer

Just execute this commands!

Installing Node.js via :

sudo apt-get install -y python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

Check version:

$ npm -v
$ node -v

For more info visit this guide.

Related Question