Updating NodeJS from v0.12.6 to 5.0.0

Word on the street there is a new security patch about to drop for NodeJS that will fix DDoS and SSH issues.

I am running an older version of NodeJS (v0.12.6) from August 2015. NodeJS has jumped to version v5.1.0 in 5 months.

I am feeling brave and I decided to upgrade my NodeJS by running these commands.

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

Then I updated my node modules.

sudo npm install npm@latest -g

Now to re ran my NodeJS service. Dang I received this error.

Error: Module version mismatch. Expected 47, got 14.
at Error (native)
at Object.Module._extensions..node (module.js:450:18)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at bindings (/redactedpath/node_modules/bcrypt/node_modules/bindings/bindings.js:76:44)
at Object. (/redactedpath/node_modules/bcrypt/bcrypt.js:3:35)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)

Thanks to Google I found this guide in seconds.

First, remove bcrypt.

sudo node remove bcrypt

The update CCC (from gcc v4.8.2 to v4.8.5).

$ 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 g++-4.8
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8

Then reinstall bcrypt.

sudo node install bcrypt

Now you should be able to run your node server.

node server.js