The npm community forum has been discontinued.
To discuss usage of npm, visit the GitHub Support Community.
Having EACCES issues that nothing seems to fix
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
The extra step you need is to repair the issues in your home
sudo chown -R $(whoami) ~/.npm
Unfortunately, I am still getting the error that the command ng was not found
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.
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?
See step 4 of the the link you used, you need to add a line to your shell startup file:
Then easiest thing to do is start another shell to see if the change is working.
you are THE MAN. Can you explain as to why this works above ^ ?
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 says that the variable should be passed along to child processes too.
Wow, now that makes sense. Thank you so much again for the help.