Problem
$ sudo npm i -g npm to update
npm ERR! code 1
npm ERR! Command failed: /usr/bin/git clone -q git://github.com/jonschlinkert/resolve-file.git /home/jp/.npm/_cacache/tmp/git-clone-6677f267
npm ERR! /home/jp/.npm/_cacache/tmp/git-clone-6677f267/.git: Permission denied
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! /home/jp/.npm/_logs/2018-04-11T09_43_12_553Z-debug.log
Solution
$ wget -O- https://www.npmjs.com/install.sh | sudo bash