sudo: npm: command not found

前端 未结 25 2670
渐次进展
渐次进展 2020-11-28 01:19

I\'m trying to upgrade to the latest version of node. I\'m following the instructions at http://davidwalsh.name/upgrade-nodejs

But when I do:

sudo np         


        
25条回答
  •  温柔的废话
    2020-11-28 01:42

    WARNING (edit)

    Doing a chmod 777 is a fairly radical solution. Try these first, one at a time, and stop when one works:

    • $ sudo chmod -R 777 /usr/local/lib/node_modules/npm
    • $ sudo chmod -R 777 /usr/local/lib/node_modules
    • $ sudo chmod g+w /usr/local/lib
    • $ sudo chmod g+rwx /usr/local/lib

    $ brew postinstall node is the only install part where I would get a problem

    Permission denied - /usr/local/lib/node_modules/npm/.github
    

    So I

    // !! READ EDIT ABOVE BEFORE RUNNING THIS CODE !!
    $ sudo chmod -R 777 /usr/local/lib
    $ brew postinstall node
    

    and viola, npm is now linked

    $ npm -v
    3.10.10
    

    Extra

    If you used -R 777 on lib my recommendation would be to set nested files and directories to a default setting:

    • $ find /usr/local/lib -type f -print -exec chmod 644 {} \;
    • $ find /usr/local/lib -type d -print -exec chmod 755 {} \;
    • $ chmod /usr/local/lib 755

提交回复
热议问题