I’d been struggling with npm installs for a while on my machine and couldn’t work out why. Various error messages kept appearing for various Node modules but it never seemed to be an issue with the modules themselves.

Finally, I encountered this error message (Gulp is an example, it was happening for all sorts of modules):

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

I hunted around the web and tried a range of things, the solution for me was running the following in my Mac OSX terminal (note – leave $USER as $USER, that’s how it is meant to be!):

sudo chown -R $USER ~/.npm

and also (as it appeared not to affect this folder):

sudo chown -R $USER ~/.npm/_locks

After that, my issues disappeared and Node and npm began to run smoothly once more! Hooray! I shall breathe a sigh of relief and continue working on my upcoming project soon to be revealed to the world!

Leave me a comment!

Your email address will not be published. Required fields are marked *