1. Upgrade nodejs


Firstly, checkout the version of nodejs:
$ node -v

If it is not the latest version, use the following commands to upgrade it.

$ sudo npm cache clean -f
$ sudo npm install -g n
$ sudo n stable
$ node -v

2. Upgrade npm 

$ npm install -g npm
Translated from: Small Feet