I was getting an EACCES error when trying to run the following command :

npm i -g node-static

the detail of error is as follows:

npm WARN checkPermissions Missing write access to /usr/local/node- 
npm ERR! path /usr/local/node-v9.11.1-linux-x64/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/node- 
npm ERR!  { Error: EACCES: permission denied, access '/usr/local/node- 
npm ERR!   stack: 'Error: EACCES: permission denied, access 
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/node-v9.11.1-linux-x64/lib/node_modules' 
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:

so I have searched for it and got a solution Here by changing ownership through either of the following commands :

sudo chown -R $(whoami) ~/.npm

or :

sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}

but then few users were saying Don't hack with permissions, install node the right way. As I'm new to Ubuntu so getting confused that whether its safe to hack permission or not .

What I am getting through upper command that it will change ownership of npm directory and its sub-directories to primary user that is me but this change of ownership is for that particular npm directory but nothing else ,right ? please suggest me whether this approach safe and good ,thank you!

  • 1
    Can you redo the installation? Follow this article digitalocean.com/community/tutorials/… or nodesource.com/blog/installing-node-js-tutorial-ubuntu and you should be fine. Don't install npm as root ;-)
    – Rinzwind
    May 11, 2018 at 13:50
  • further I found installing node through PPA (nodesource) is quiet easy but at some places people suggest that its not advisable to allow root permissions to private repositories so my question is will it be really safe practice to install through it or if I am concerned about safety then I should install it through some other way ? thank you!
    – user716691
    May 11, 2018 at 14:11


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy