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

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

    Disclaimer

    I am a Windows user. However, my team and I have come across a number of issues regarding npm installaion errors.

    Problems

    The following is a list of lessons learned and a possible radical solution that has always rescued us:

    1. node_modules, the npm local installation directory becomes protected from modification by a shortcoming of the OS such as the inability to process paths longer than 255 characters.
    2. If the folder is erased by means of a command line tool it may still appear as if the folder exists in the explorer that when trying to access it gives a number of permission errors.
    3. Depending on your antivirus and/or local policy manager you may be able to create the node_modules folder and later relegated access or permissions to it resulting in a number of installation errors.
    4. Enable npm logs to gain further insight into possible problems with:

      npm install --loglevel verbose

    Radical

    Install rimraf globally

     npm install rimraf -g
    

    Run rimraf on node_modules:

    rimraf yourDir/node_modules
    

    Then try running:

    npm install
    

    Warning!

    Or lack there of. Be extremely careful about what follows the command rimraf. There are no warnings, no prompts, there is nothing. It simply erases the directory from the phase of the earth clean, as if it was never there. Try it at your own risk.

提交回复
热议问题