Node.jsexit code > 0

npm ERR! code EACCES

$npm ERR! code EACCES npm ERR! syscall access npm ERR! path /usr/lib/node_modules

Analysis

NPM does not have permission to write to the directories it needs to install packages (usually global modules).

Common Triggers

  • Installing global packages without sudo (not recommended).
  • Node/NPM installed with root permissions originally.

Debug Checks

  • $Check permissions of the folder mentioned in the error.

Resolution

1
Use a Node Version Manager (nvm) to avoid permission issues (Best Practice).
2
Change ownership of the npm directory.