Global Node modules not installing correctly. Command not found

前端 未结 9 1088
北荒
北荒 2020-11-29 20:26

I am having a problem installing global node modules and everything I find online says the solve is just adding -g. Which is not the problem. I believe it\'s a linking issue

9条回答
  •  孤街浪徒
    2020-11-29 20:33

    My npm couldn't find global packages as well. I did what Brad Parks suggested:

    npm config set prefix /usr/local
    

    Then I got a EACCES permissions error (DON'T USE sudo npm install -g ) and fixed it through the official npm docs: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

    1. On the command line, in your home directory, create a directory for global installations:
     mkdir ~/.npm-global
    
    1. Configure npm to use the new directory path:
     npm config set prefix '~/.npm-global'
    
    1. In your preferred text editor, open or create a ~/.profile file and add this line:
     export PATH=~/.npm-global/bin:$PATH
    
    1. On the command line, update your system variables:
     source ~/.profile
    
    1. Then install a package globally and test it! For example:
    npm install -g awsmobile-cli
    awsmobile configure
    
    

提交回复
热议问题