NPM cannot install dependencies - Attempt to unlock something which hasn't been locked

前端 未结 9 1575
独厮守ぢ
独厮守ぢ 2020-12-02 03:59

I\'ve been trying to run an npm install on my package.json file, but I\'m having a lot of trouble. It keeps saying \"Error: Attempt to unlock XXX, which hasn\'t been locke

9条回答
  •  攒了一身酷
    2020-12-02 04:22

    Had the same issue and fixed it by changing the persmissions as per the accepted answer:

    sudo chown -R $USER ~/.npm
    

    However, the second command should be avoided as it downgrades the permissions of a system resource (sudo chown -R $USER /usr/local/lib/node_modules). Not a good idea.

    For the record: "usr" in /usr/local stands for Unix System Resources.

提交回复
热议问题