EACCES error when trying to update Ionic CLI [solved]

My console is telling me to update Ionic CLI to the latest version, but running npm install -g ionic results in an EACCES error. I don’t want to run the command using sudo because I remember when I’ve done that previously that can mess things up.

What are my options for working around this issue?

Code below:

------------------------------------
Ionic CLI is out of date:
 * Locally installed version: 1.7.10
 * Latest version: 1.7.14
 * https://github.com/driftyco/ionic-cli/blob/master/CHANGELOG.md
 * Run npm install -g ionic to update
------------------------------------

stewart@sfml-stewart ~/Code/phone-signup $ npm install -g ionic
npm ERR! Darwin 14.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "ionic"
npm ERR! node v0.12.5
npm ERR! npm  v2.11.2
npm ERR! path /usr/local/lib/node_modules/ionic/.gitattributes
npm ERR! code EACCES
npm ERR! errno -13

npm ERR! Error: EACCES, unlink '/usr/local/lib/node_modules/ionic/.gitattributes'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES, unlink '/usr/local/lib/node_modules/ionic/.gitattributes']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/ionic/.gitattributes' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.
npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/ionic/.gitattributes'
npm ERR! error rolling back     at Error (native)
npm ERR! error rolling back  { [Error: EACCES, unlink '/usr/local/lib/node_modules/ionic/.gitattributes']
npm ERR! error rolling back   errno: -13,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   path: '/usr/local/lib/node_modules/ionic/.gitattributes' }

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/stewart/Code/phone-signup/npm-debug.log

Found the answer:

Run this:

sudo chown -R `whoami` /usr/local/lib/node_modules/ionic/

Answer credit: https://github.com/driftyco/ionic/issues/2555

1 Like