0

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!

Dino
  • 7,779
  • 12
  • 46
  • 85
Eduardo
  • 264
  • 2
  • 10

3 Answers3

2

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.

Will Alexander
  • 3,425
  • 1
  • 10
  • 17
  • This is the solution I use on every linux machine and works like a charm – Manos Kounelakis Aug 16 '19 at 05:37
  • thank you @Will Alexander will give this a try in a few hours! – Eduardo Aug 16 '19 at 15:15
  • On my text editor, Visual Studio Code i tried to create a profile by entering ```~/.profile``` into the terminal but the permission was denied – Eduardo Aug 16 '19 at 17:03
  • Something "strange" happened as i was able to install the framework via the terminal on Visual Studio Code. This, after entering both ```mkdir ~/.npm-global```and ```npm config set prefix '~/.npm-global'``` (Mac Terminal) And once in the VSC terminal i used ```sudo npm install -g @angular/cli``` – Eduardo Aug 16 '19 at 17:08
  • Another thing, i tried to make a new app via the VSC terminal by using ```ng new my-app``` and it did not worked, but on the Mac Terminal it seems it has been. So im unsure if the installation needs something else. Why? – Eduardo Aug 16 '19 at 17:13
  • Another comment, the problem seems to be around the fact that my permit is denied to making folders, I get ```EACCES: permission denied, mkdir '/my-app'``` – Eduardo Aug 16 '19 at 17:15
  • Is your computer account an Admin one? Where are you trying to create directories? – Will Alexander Aug 16 '19 at 17:20
  • Yes it's basically the only account I use all the time. This particular directory ```.npm-global``` which is hidden is under my username so the path is: USER/.npm-global, thanks. – Eduardo Aug 16 '19 at 17:42
0

Try logging in as a super user.

sudo npm install -g @angular/cli

Hope it works!

0

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.

Eduardo
  • 264
  • 2
  • 10