Julien Julien - 1 year ago 338
Node.js Question

Error This version of node/NAN/v8 requires a C++11 compiler

I've recently upgraded Nodejs from 0.13 to 6.9 and I started getting some errors when running my nodejs app, I googled around, managed to fix some errors and new ones appeared, I ended up deleting the

folder of my app, clearing npm's cache and running the npm install again and this is where I am stuck, you can see the full output in this pastebin.

More details:

  • Ubuntu 12.04

  • Nodejs v6.9.1 (both
    node --version
    nodejs --version
    return the same)

  • node-gyp, clang, gcc, make and build-essential are all installed

Node modules my app uses:

"dependencies": {
"socket.io": "~1.2.1",
"kurento-client": "Kurento/kurento-client-js",
"mongoose": "~3.8.23",
"dateformat": "~1.0.11",
"underscore": "~1.8.3"

I've been trying the solutions from here to no avail.

How can I fix this?

Answer Source

Finally solved this, I'll leave the solution here for whomever runs into the same problem.

Here's what the problem was, Unbuntu 12.04 only has gcc 4.6.3 in the official repository, but C++11 is only supported from 4.8.1, therefore you need to install 4.8 from a different PPA:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50

Now this alone did not fix the problem since it seems node-gyp uses g++ instead of gcc so just do the same for g++:

sudo apt-get install g++-4.8
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50

after that sudo npm install should run without problems.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download