How to compile/install node.js(could not configure a cxx compiler!) (Ubuntu).

LinuxUbuntuCompilationInstallationnode.js

Linux Problem Overview


How can I compile/install node.js on Ubuntu? It failed with an error about cxx compiler.

Linux Solutions


Solution 1 - Linux

One-liner to install all needed dependencies(curl and git are not really needed, but are very useful and also needed if you install via nvm).

sudo apt-get install build-essential libssl-dev curl git-core

Last two dependencies are not always needed, but installing them is really usefull anyway and you probably need it later anyway.

To only install cxx compiler

sudo apt-get install build-essential

If openssl is missing

sudo apt-get install libssl-dev

Solution 2 - Linux

If like me, you are attempting to install this on an AWS instance running Amazon Linux AMI (which looks to be a cut down version CentOS):

Install base tools:

yum groupinstall "Development Tools"

Now install openssl-devel:

yum install openssl-devel

Node should compile fine now.

Solution 3 - Linux

If you're attempting this on Win7 like me, running:

ash.exe
$ /bin/rebaseall

...did the trick.

Good luck!

Solution 4 - Linux

If you find yourself getting this error on Mac OSX, you need to install XCode.

https://developer.apple.com/

Solution 5 - Linux

I needed to run yum install gcc-c++ on Cent OS.

Solution 6 - Linux

There is a package for it on launchpad.
https://launchpad.net/~chris-lea/+archive/node.js/

Solution 7 - Linux

For Node.js v6:

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

For Node.js v7:

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

Optional: install build tools To compile and install native addons from npm you may also need to install build tools:

sudo apt-get install -y build-essential

After to get latest NPM packages, if you need:

npn update -g

Partial source here.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAlfredView Question on Stackoverflow
Solution 1 - LinuxAlfredView Answer on Stackoverflow
Solution 2 - LinuxJay SidriView Answer on Stackoverflow
Solution 3 - LinuxNicholas BlumhardtView Answer on Stackoverflow
Solution 4 - LinuxmjamalView Answer on Stackoverflow
Solution 5 - LinuxKelstarView Answer on Stackoverflow
Solution 6 - LinuxnolazybitsView Answer on Stackoverflow
Solution 7 - LinuxPax BeachView Answer on Stackoverflow