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 node_modules 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:

  • Get the list of latest tweets using node.js and twitterAPI
  • Uploading an image file with Nightwatch.js
  • Closing a socket server side on socket.io?
  • Are there any pre-built binaries for Node.JS on Solaris?
  • Working with Node.JS
  • Visual Studio Code - Node.js - Cannot find name '__dirname'
    • Ubuntu 12.04
    • Nodejs v6.9.1 (both node --version and 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?

  • Error in MySQL library for Node.js
  • How do I run MULTIPLE shell commands in a gruntjs task?
  • cannot get nodejs working on amazon ec2 instance
  • Sending mails with attachment via NodeJS
  • Fetch API and multer error while uploading file
  • How to compile jade template file to get string?
  • One Solution collect form web for “Error This version of node/NAN/v8 requires a C++11 compiler”

    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.

    Node.js is the Best Javascript runtime in the world.