Skip to content

Instantly share code, notes, and snippets.

@natural-affinity
Last active February 14, 2016 10:13
Show Gist options
  • Select an option

  • Save natural-affinity/b95f25968220e794c189 to your computer and use it in GitHub Desktop.

Select an option

Save natural-affinity/b95f25968220e794c189 to your computer and use it in GitHub Desktop.
NPM EACCESS Problems (sudo)

Description

Assuming the OSX Node Installer was used with your current user as the medium,
the root of the problem seems to stem from incorrect ownership of the node_modules
directory (not so much the /usr/local directory).

$ ls -l /usr/local/lib

This will show that the ownership belongs to user 24561 which was probably assigned
by the node installer. Hence, issuing npm install commands with sudo essentially override
and prevent the EACCESS error. However, we still tend to see additional access errors with
other npm moddules such as yeoman when they try to install dependency packages.

Performing the following command should fix the issue:

$ chown -R $USER /usr/local/lib/node_modules

However, keep in mind that existing cached modules (if they were installed via sudo) would still
have access problems. As such clear the cache one final time with sudo:

$ sudo npm cache clear

FYI: The npm cache is stored in the $USER/.npm directory.

To speed up npm:

$ npm set progress=false

Linux

Use NVM: https://github.com/creationix/nvm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment