My question is simple but I couldn't find answers

I need to use sudo npm install but I need the files installed to have my user's ownership, not root's.

For example: sudo touch a will give me a file owned by root, not by my actual user who's running sudo.

Also, when I do sudo npm install link_from_github I'm getting permission denied because npm launches git clone. But why git clone is launched without root permissions if I ran everything in sudo?

  • This would need the program doping the installation to realise it's being run using sudo and then cooperate, which is not at all likely to happen. – muru Mar 18 '18 at 4:35
  • @muru I thought sudo simply made my user be able to write to any folder. Is there something that does this? – Guerlando OCs Mar 18 '18 at 4:42
  • 1
    no, sudo runs the command as a different user/group. It doesn't give your user extra privileges. – muru Mar 18 '18 at 4:46
  • 1
    The question is confusing. However, from the sound of it, it seems you are either using the wrong directories, or that you should work on the permissions of your directories, or both. It is not entirely clear what you are asking. You should not being using sudo to get around problems of a bad setup. – Rui F Ribeiro Mar 18 '18 at 8:17

Your Answer

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

Browse other questions tagged or ask your own question.