npm throws error without sudo

前端 未结 30 1732
清酒与你
清酒与你 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:23

    For Mac (adopted from Christoper Will's answer)

    Mac OS X 10.9.4

    1. System Preference > Users & Groups > (unlock) > press + :

      New Account > "Group"
      Account Name : nodegrp

      After creating the group, tick the user to be included in this group

    2. sudo chgrp -R nodegrp /usr/local/lib/node_modules/
      sudo chgrp nodegrp /usr/bin/node
      sudo chgrp nodegrp /usr/bin/npm
      sudo chown -R $(whoami):nodegrp ~/.npm

提交回复
热议问题