Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I just got a new macbook and installed node.js using the official installer.

For some reason I can only run node.js using sudo node and not just node. I double checked the $PATH and the path to node is in there.

nikke at Nicks-MacBook-Pro in ~
$ node
-bash: node: command not found
nikke at Nicks-MacBook-Pro in ~
$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/Users/nikke/.rvm/bin
nikke at Nicks-MacBook-Pro in ~
$ /usr/local/bin/node -v
-bash: /usr/local/bin/node: Permission denied
nikke at Nicks-MacBook-Pro in ~
$ sudo /usr/local/bin/node -v
v0.10.12

My colleague has the same computer and he can run node just fine without having to do sudo. Is this normal? What could I possibly do wrong? The installer didn't say anything about having to do sudo.

I am also having this problem with git, e.g. doing git commit also says Permission denied.

share|improve this question
2  
Can you show us node and its directories rights and owner please? –  ssssteffff Jun 28 '13 at 16:46
    
Let me guess, the colleague installed node, right? What's the output of ls -l /usr/local/bin/node? –  David Schwartz Jun 28 '13 at 18:04

2 Answers 2

up vote 1 down vote accepted

There are two parts to this phenomenon - i>The location or ii>the nature, of the file may require you to sign in as the administrator as it may act in a way to destabilise the system, or you may simply NOT have the required permissions to execute the file.

As for it working on the colleague's computer, it may be due to a variation of the above mentioned factors.

Try changing the permission of the file(for which you may again need admin rights). If possible, you may also try executing it at a separate location. Sudo does the job perfectly by elevating your position as the Admin of the OS (who has the required rights). This is one of the many security checks native to the OS, to prevent accidental change/damage of the system.

IMP: Your selected location has precious system related files, which the user does not have the right to edit.

Also, did your friend previously log in as the superuser, using

su

??

If so, then he already logged in as the superuser and does not need to log in again. The root user privileges is indicated by the # at the end of the prompt instead of $.

share|improve this answer
    
Thanks for the detailed response! Will check it, indeed your suggestion that he might run su is valid. –  Nick Jun 28 '13 at 20:23
    
@Nick : You're welcome.. :) –  Somu Jun 29 '13 at 18:43
    
You're right, it was a permissions issue in the end. My collegue did sudo chmod go+rwx /usr/local/bin and then it started to work! Thanks again :) –  Nick Jul 1 '13 at 8:38

Probably because the program /usr/local/bin/node is not allowed to be run by "normal" users. You apparently need to be the root user to run it. That is why sudo is needed.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.