npm throws error without sudo

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

    Changing the owner on "system-global" folders is a hack. On a fresh install, I would configure NPM to use an already writable location for "user-global" programs:

    npm config set prefix ~/npm
    

    Then make sure you add that folder to your path:

    export PATH="$PATH:$HOME/npm/bin"
    

    See @ErikAndreas' answer to NPM modules won't install globally without sudo and longer step-by-step guide by @sindresorhus with also sets $MANPATH.

提交回复
热议问题