Tell me more ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I was trying to install npm, and I got

npm ERR! Error: EACCES, Permission denied '/usr/local/lib/node_modules'
npm ERR! 
npm ERR! Please use 'sudo' or log in as root to run this command.
npm ERR! 
npm ERR!     sudo npm "install" "." "--force" "--global"
npm ERR! 
npm ERR! or set the 'unsafe-perm' config var to true.
npm ERR! 
npm ERR!     npm config set unsafe-perm true

How can log in as a root?

share|improve this question
Do not login as root. ;-) – Chris Page Apr 6 '12 at 13:14

3 Answers

up vote 11 down vote accepted

sudo -s is far easier than enabling the root user.

share|improve this answer
5  
But better to sudo the one command rather than run under a shell as root – Mark Jun 19 '11 at 20:52

You need to use the su (switch user) command to become root, but only root is allowed to become root, so you need to use sudo (super-user do). Therefore, type: sudo su.

[william@NCC-1701 ~]$ sudo su
Password:
[root@NCC-1701 /Users/william]$ 

If you haven't used root before, you should be made fully aware that one wrong character typed as root will delete your entire operating system, including your photos, emails and financial documents. Be extremely careful and always triple-read what you type before hitting enter. Otherwise, good luck!

share|improve this answer
1  
been an AIX support technician for 3 years ... 12 years ago :) know some stuff but the simple stuff had vanished from my head :) – balexandre May 18 '11 at 18:51
I was going to snark my answer with friendly manual and google suggestions but quickly deleted it after reading your bio. Welcome to mac. I still can't bring myself to type vm_stat after years of AIX. Gotta love shell aliases ;-) – bmike May 18 '11 at 19:15
Why use sudo su instead of sudo -s? – Chris Page Apr 6 '12 at 13:13

I usually do it bit differently than how others described here. Lets imagine you have two users. standard user: john admin user: kevin

If john is logged in and wants to run as a root user(as kevin) here is how I do it.

su kevin

when asked enter kevin's password

sudo npm "install" "." "--force" "--global"

enter kevin's password again.

share|improve this answer
After you've already switched user to kevin, why do you need the sudo? – cm2 Jan 16 '12 at 17:29

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.