Random thoughts & observations

From the mundane to the profound and everything in between here’s what’s rocking our world

Ionic framework attempt to unlock file that has not been locked error

Posted: March 14, 2015
Written by: Saints At Play
Category: Ionic Framework

Here's a frustrating issue we encountered when trying to update the ionic framework with the following command:

sudo npm update -g ionic

Instead of seeing a list of updated components being displayed in the console the following error occurred:

npm WARN locking Error: EACCES, open '/Users/nameHere/.npm/_locks/ionic-61c0cd50dc7a1457.lock'
npm WARN locking     at Error (native)
npm WARN locking  /Users/nameHere/.npm/_locks/ionic-61c0cd50dc7a1457.lock failed { [Error: EACCES, open '/Users/nameHere/.npm/_locks/ionic-61c0cd50dc7a1457.lock']
npm WARN locking   errno: -13,
npm WARN locking   code: 'EACCES',
npm WARN locking   path: '/Users/nameHere/.npm/_locks/ionic-61c0cd50dc7a1457.lock' }
npm ERR! Darwin 13.4.0
npm ERR! argv "node" "/usr/local/bin/npm" "update" "-g" "ionic"
npm ERR! node v0.12.0
npm ERR! npm  v2.7.1

npm ERR! Attempt to unlock /usr/local/lib/node_modules/ionic, which hasn't been locked

Not the most welcome of sights is it? Thankfully solving this turned out to be relatively quick and easy.

What is going on?

As the node package manager runs through updating the installed version of the Ionic Framework software it falls foul when attempting to unlock a file that isn't locked. This appears to happen due to problems with the permissions settings on the npm directory itself.

Running the following command changes ownership of the npm directory, and all its contents, to the current user:

sudo chown -R $USER ~/.npm

As an alternative to the above, you could try using a slightly modified version of the command like so:

sudo chown -R `whoami` ~/.npm

This slight variation uses the whoami shell command to determine the current system user (the back ticks surrounding the command ensure that it is executed correctly) and assigns ownership of the npm directory to that user instead.

Now, if you try re-running the ionic update command:

sudo npm update -g ionic

Then you should find the operation proceeds without any lock errors or similar issues and your installation of Ionic is up to date with the latest version (which at the time of writing is 1.3.14).

« Return to Posts

Comments

There are no comments

Posting comments after three months has been disabled.