Error “Your cache folder contains root-owned files, due to a bug in previous versions of npm” while “npx create-react-app example_app”

前端 未结 9 2426
灰色年华
灰色年华 2021-02-12 21:48

When I was trying to create a new react app using npx create-react-app example_app, I get this error

[Your cache folder contains root-owned

相关标签:
9条回答
  • 2021-02-12 22:25

    It work for me now!

    What I did? (I'm not saying it's the best way to fix this but i'ts working for me. I'm still looking for the best explications for this issue)

      sudo rm -Rf /home/[YOUR_USER_NAME]/.npm-global/lib/node_modules/
    

    and run your command again.

    My explication is that it seems like something is corrupted in the node_modules's folder. As it's not risky to delete it I did it and it works now.

    0 讨论(0)
  • 2021-02-12 22:25

    This will work: sudo chown -R 1000:1000 "~/.npm"

    0 讨论(0)
  • 2021-02-12 22:31

    I had the same issue and several others while trying to update my npm packages. I will be honest I do not have enough knowledge of package handlers or why this fixed my situation, but I believe my version of npm and npx were causing the issues. I had errors immediately trying to install npx, node and create-react-app with my old and out of date version of npm.

    I could not run npm install npx -g without --force. Once I did that I also ran npm install npm -g --force. After this I could already tell things were different.

    After npm and npx were completely overwritten, I ran npm install node -g and npm install create-react-app -g without any weird problems. I created a new react app and started it error free.

    (I also ran the cache command before all of this. sudo npm cache clean --force which I am unsure if it helped).

    0 讨论(0)
  • 2021-02-12 22:32

    Try sudo chown -R 1000:1000 "/home/shubham/.npm"

    0 讨论(0)
  • 2021-02-12 22:35

    This worked for me:

    sudo npm cache clean --force 
    
    0 讨论(0)
  • 2021-02-12 22:38

    This is what helped me after going through the above answers. I hope it helps someone else too. After re-reading the npm error prompt, I adjusted the provided command to include the .npm path given in the error message. Below is a copy of my original error messages.

    npm ERR! code EACCES

    npm ERR! syscall access

    npm ERR! path /home/vagrant/.npm-global/lib/node_modules

    npm ERR! errno -13

    npm ERR!

    npm ERR! Your cache folder contains root-owned files, due to a bug in

    npm ERR! previous versions of npm which has since been addressed.

    npm ERR!

    npm ERR! To permanently fix this problem, please run:

    npm ERR! sudo chown -R 900:900 "/home/vagrant/.npm"

    npm ERR! A complete log of this run can be found in:

    npm ERR! /home/vagrant/.npm/_logs/2020-07-09T16_43_35_046Z-debug.log

    [ExecStack] Exit code 243 Time 01:03

    [error] Executing target-hook frontend-reqs failed.

    [error] Command source:build:frontend-reqs exited with code 1.

    Instead of using sudo chown -R 900:900 "/home/vagrant/.npm", I used sudo chown -R 900:900 "/home/vagrant/.npm-global". After that, I was able to use the previous command that caused the error with no issues.

    0 讨论(0)
提交回复
热议问题