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-
v9.11.1-linux-x64/lib/node_modules
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-
v9.11.1-linux-x64/lib/node_modules'
npm ERR! { Error: EACCES: permission denied, access '/usr/local/node-
v9.11.1-linux-x64/lib/node_modules'
npm ERR! stack: 'Error: EACCES: permission denied, access
\'/usr/local/node-v9.11.1-linux-x64/lib/node_modules\'',
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!