Install errors with node v4 and v5 #776

While building  a nodejs application (npm install) I came across some weird issues which are in a nutshell as follows.
v8.h:336:1: error: expected unqualified-id before ‘using’,  node-gyp

The nodejs version I was using was v5.10.1 and the reason for this issue was incompatible gcc. and upadating gcc to correct version solved the problems. Following steps are what I did to fix the issue.

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-5 g++-5
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 80 --slave /usr/bin/g++ g++ /usr/bin/g++-5
sudo update-alternatives --config gcc (choose gcc-5 from the list)

Check that the correct versions of gcc and g++ are being used by default by running gcc -v; g++ -v