Having EACCES issues that nothing seems to fix

(Nick Giannini) #1

I was having an issue with installing the angular cli. The command ng wasn’t running, so I used this link to fix my issues – https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally – but now I am getting even more of an error when just trying to use the npm command on the command line

(John Gee) #2

The extra step you need is to repair the issues in your home .npm folder:

sudo chown -R $(whoami) ~/.npm

The canonical bug is: Global installs (sudo npm i -g) fail on Mac after 6.5 upgrade. Works fine after 6.4.1 downgrade.

(Nick Giannini) #3

Unfortunately, I am still getting the error that the command ng was not found

(John Gee) #4

The chown was to fix the EACCES error. Hopefully now can tackle the ng issue. I am not familiar with angular, so checking some basic questions. Someone else may jump in with a quicker route to a solution. :slight_smile:

What is your prefix now?

npm prefix --global

Have you reinstalled the angular cli since changing the npm prefix?

Do you have the bin folder from your prefix listed in your PATH?

echo $PATH

(Nick Giannini) #5


(John Gee) #6

See step 4 of the the link you used, you need to add a line to your shell startup file:

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

Then easiest thing to do is start another shell to see if the change is working.

(Nick Giannini) #7

you are THE MAN. Can you explain as to why this works above ^ ?

(John Gee) #8

Well, it it is both simple and complex. Off the top of my head and not checking the strict definition of anything…

When you type ng, the shell checks for an executable file called ng in each of the directories in PATH, and runs the first one it finds. The directories in PATH are separated by :.

When you have the npm global prefix set to ~/.npm-global and install an npm package that adds a cli command such as ng, the cli command gets added at ~/.npm-global/bin/ng. Without making changes, the shell does not know to check there.

This line takes the existing value for PATH and inserts ~/.npm-global/bin on the front so the shell will check there first.

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

The export says that the variable should be passed along to child processes too.

(Nick Giannini) #9

Wow, now that makes sense. Thank you so much again for the help.

(system) closed #10

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.