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

前端 未结 9 1576
独厮守ぢ
独厮守ぢ 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:13

    As per photusenigma at: https://github.com/npm/npm/issues/4815

    Run these commands in a terminal window (note - DON'T replace the $USER part...thats a linux command to get your user!):

    sudo chown -R $USER ~/.npm
    sudo chown -R $USER /usr/local/lib/node_modules
    

    ...and...if you're on a mac (like I am), and still see errors after running these commands, then run this last one and you should be good. (Recommend you try testing before you do this one. I don't like changing the permissions on the ENTIRE /usr/local directory unless it really seems necessary!)

    sudo chown -R $USER /usr/local
    

提交回复
热议问题