Tuesday, December 23, 2014

npm ERR! Error: Attempt to unlock *******, which hasn't been locked

I encountered this error when I was trying to install dependencies for angular-phonecat. The error is misleading. You must be wondering why NPM is trying to unlock something that is not locked. Attempting to run the npm install with sudo as well does not fix the problem. 

The root cause of this problem is that the user who is trying to download npm packages is not the owner of the folder in which the installed packages will be stored.

To fix this, run the following command

sudo chown -R $(whoami) $HOME/.npm