npm throws error without sudo

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

    In case sudo chown -R $(whoami) ~/.npm didn't work for you, or you need a non terminal command solution.

    The issue is that your user account does not have write permission to node_modules folder, so you can do the following

    1. Open finder and press cmd + shift + g this will open go to folder with url

    2. Write the following path /usr/local/lib/node_modules and press go

    3. Right click on node_modules folder and choose Get Info

    4. Scroll down to sharing & permissions section

    5. Unlock to be able to make changes.

    6. Press + and add your user account

    7. Make sure that you choose Read & Write in privilege drop down

    Now you should be able to install packages without sudo and permission issues should be solved

提交回复
热议问题