Cant install Angular on MacOS

I can't install the framework Angular on my Mac.

Mac version: macOS Mojave version 10.14.6

The terminal suggest I should be using an admin account to make this installation work.

This is what I have been using to the terminal for the install:

npm install -g @angular/cli

This is the error displayed, copying and pasting the code is not comprehensive so instead I made the snapshot.

Error Please help!

3 answers

  • answered 2019-08-16 05:34 Will Alexander

    This problem is well known on macOS machines, and is linked to how your OS protects certain directories. Here is the procedure recommended in the NPM docs:

    • Back up your computer.
    • 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

    Alternatively, you can install NodeJS and NPM using a version manager like nvm. With both of these methods, you are simply creating and defining a new directory where all of your NPM stuff will be installed. This prevents you from having to use sudo to install packages.

  • answered 2019-08-16 11:11 akshayprasad

    Try logging in as a super user.

    sudo npm install -g @angular/cli

    Hope it works!

  • answered 2019-08-16 21:33 Eduardo

    I was able to install angular using brew. Use this link to find more about how to install Brew on your macOS, and about Angular while using brew the details are here. You only need to run brew install angular-cli I think on the terminal, so I hope that works out for anyone else having issues regarding this frameworks installation.