npm throws EACCES error on installation of Angular CLI

后端 未结 9 605
没有蜡笔的小新
没有蜡笔的小新 2020-12-11 15:34

I am unable to install Angular Cli globally through npm. I keep getting this error when I run npm install -g @angular/cli on macOS:

npm ERR! nod         


        
9条回答
  •  清歌不尽
    2020-12-11 15:55

    Try using this: On the command line, in your home directory, create a directory for global installations:

    mkdir ~/.npm-global
    

    Configure npm to use the new directory path:

    npm config set prefix '~/.npm-global'
    

    In your preferred text editor, open or create a ~/.profile file and add this line:

    export PATH=~/.npm-global/bin:$PATH
    

    On the command line, update your system variables:

    source ~/.profile
    

    Test installing package globally without using sudo. Now run npm install -g @angular/cli it should work.

提交回复
热议问题