Npm start issues in AngularJS phonecat application

These errors mean that npm cannot access the directory /Users/twer and its subdirectories because of the wrong permissions.

You want to run npm with your own user permission, so set them with by changing the ownership with

chown -R $USER <directory>

or

chown -R `whoami` <directory>

— both commands do the same, where <directory> is:

  • your home directory (/Users/twer) for local installations;
  • your machine directory for non-system packages, /usr/local or whatever top directory is npm trying to use, that you see in your error messages, you would likely need to prefix your command with sudo in that case.

The option -R here is for recursive as it sets correct ownership also to all subdirectories, which is exactly what you want.

You want to avoid running npm with sudo ever, as recommended by the npm creator Isaac Schlueter:

I strongly encourage you not to do package management with sudo! Packages can run arbitrary scripts, which makes sudoing a package manager command as safe as a chainsaw haircut. Sure, it’s fast and definitely going to cut through any obstacles, but you might actually want that obstacle to stay there.

Leave a Comment