If you want to install some packages using npm and you are getting this kind of error “Warning “root” does not have permission to access the dev dir“, that means that system is trying to compile some native libraries with a wrong user and so lead to an unability to gain access on certain directories.
To fix this, just use this command instead (in this example, I’m installing ‘sails‘):
sudo npm install --unsafe-perm --verbose -g sails
It should do the trick 😉