73

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

Alfred
  • 60,935
  • 33
  • 147
  • 186

7 Answers7

116

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
Alex Dean
  • 15,575
  • 13
  • 63
  • 74
Alfred
  • 60,935
  • 33
  • 147
  • 186
  • 4
    I also found this very good tutorial explaining how to install node.js on ubuntu => http://www.codediesel.com/linux/installing-node-js-on-ubuntu-10-04/ – Alfred Dec 05 '10 at 02:26
45

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.

Jay Sidri
  • 6,271
  • 3
  • 43
  • 62
8

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

ash.exe
$ /bin/rebaseall

...did the trick.

Good luck!

Nicholas Blumhardt
  • 30,271
  • 4
  • 90
  • 101
  • 1
    I think you should make this a separate topic if it does not exist. Then when users google for compiling node.js for windows they will find your topic. – Alfred Dec 25 '10 at 20:53
  • 1
    Should be worth noting that Nicholas is compiling node in Windows using cygwin. `ash.exe` and `rebaseall.exe` are utilities that ship with cygwin. – Jay Sidri Jun 23 '11 at 06:17
  • 1
    Running `ash.exe` in bash gave me weird output. I opened a normal `cmd` instead, and ran `cd C:/cygwin/bin,`, then `dash.exe` (A better `ash.exe` supposedly, but either works). Then used `./rebaseall` – Dominic K Aug 28 '11 at 03:15
6

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

https://developer.apple.com/

mjamal
  • 96
  • 1
  • 4
3

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

Kelstar
  • 810
  • 6
  • 15
2

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

nolazybits
  • 497
  • 4
  • 19
2

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.

Pax Beach
  • 2,059
  • 1
  • 20
  • 27