This indicates that you do not have permission to write to the directories that npm uses to store global packages and commands.
How bad is it?
npm ERR! Linux 3.19.0-49-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "hapi"
npm ERR! node v7.5.0
npm ERR! npm v4.1.2
npm ERR! path /usr/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR! { Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/lib/node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! /home/light/npm-debug.log
You can fix this problem using one of three options:
- Change the permission to npm’s default directory.
- Change npm’s default directory to another directory.
- Install node with a package manager that takes care of this for you.
How to Fix?
Please check this gist
- Run
cd ~
- Run
wget http://pastebin.com/raw/1ccE6EgF -O fix_npm.sh
- Run
chmod +x fix_npm.sh
- Run
./fix_npm.sh