'whoami' does not work on mac terminal

17,530

You have a typo: you need to use backward ticks

sudo chown -R `whoami` ~/.npm
Share:
17,530
Andrew Chaa
Author by

Andrew Chaa

A developer and a code journey man. I write down what I learn: https://github.com/andrewchaa/til

Updated on June 08, 2022

Comments

  • Andrew Chaa
    Andrew Chaa almost 2 years

    When I set up Node js environment, I often encounter npm permission error, as it can't access /node-modules/. With the help of this question (npm throws error without sudo), I managed to change the ownership. However, I had to type my username, instead of 'whoami' as in the example.

    sudo chown -R 'whoami' ~/.npm
    chown: whoami: illegal user name
    

    Does it mean 'whoami' is not supported on mac, or am I doing something wrong?