npm throws error without sudo

前端 未结 30 1984
清酒与你
清酒与你 2020-11-21 07:43

I just installed node and npm through the package on nodejs.org and whenever I try to search or install something with npm it throws the following error, unless I sudo the c

30条回答
  •  爱一瞬间的悲伤
    2020-11-21 08:09

    When you run npm install -g somepackage, you may get an EACCES error asking you to run the command again as root/Administrator. It's a permissions issue.

    It's easy to fix, open your terminal (Applications > Utilities > Terminal)

    sudo chown -R $USER /usr/local/lib/node_modules
    

    ** I strongly recommend you to not use the package management with sudo (sudo npm -g install something), because you can get some issues later **

    Reference: http://foohack.com/2010/08/intro-to-npm/

提交回复
热议问题