Categories: reactjs, macos, sudo

Create-react-app couldn't generate and has errors

2 answers

I haven't code for a while and want to get back into it. When I tried to run: npx create-react-app my-app, this is what returned to me:

Creating a new React app in /Users/kyhongle/Desktop/my-app.

Installing packages. This might take a couple of minutes.

Installing react, react-dom, and react-scripts with cra-template...

npm ERR! code EACCES

npm ERR! syscall mkdir

npm ERR! path /Users/kyhongle/.npm/_cacache/content-v2/sha512/0b/62

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 501:20 "/Users/kyhongle/.npm"

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

npm ERR! /Users/kyhongle/.npm/_logs/2020-03-18T21_14_29_829Z-debug.log

Aborting installation.

npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.

Deleting generated file... package.json

Deleting my-app/ from /Users/kyhongle/Desktop

Done.

I am not sure how to go from here. Before that I did something, probably shouldn't have, I ran a sudo npm cache clean -f. I think that could have been what causing this problem. If someone can help me reverse this, I would really appreciate it!

All answers to this question, which has the identifier 60747672

The best answer:

The answer is in your trace:

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

npm ERR! sudo chown -R 501:20 "/Users/kyhongle/.npm"

sudo chown -R 501:20 "/Users/kyhongle/.npm" 

And I'm pretty sure you don't need to run npm cache clean -f as sudo, for future reference.

The code EACCES is a permissions error code.

First you can try sudo npx create-react-app my-app.

Or in your stacktrace, try running sudo chown -R 501:20 "/Users/kyhongle/.npm" to recursively change the owner of the directory and it's files.

Last questions

how do i remove the switch on my home screen?
how to edit the JS date and time to update atuomatically?
How to utilize data stored in a multidimensional array
Powermockito not mocking URL constructor in URI.toURL() method
Android Bluetooth LE Scanner only scans when phone's Location is turned on in some devices
docker wordpress container can't connect to mysql container
How can I declare a number in java that is more than 64-bits? [duplicate]
Optaplanner solutionClass entityCollectionProperty should never return null error when simple JSON object passed to controller
Anylogic, get the time a pedestrain is in a queue
How do I fix this syntax issue with my .flex file?
Optimizing query in PHP
How to find the highest number of a column and print two columns of that row in R?
Ideas on “Error: Type com.google.firebase.iid.zzav is referenced as an interface from com.google.firebase.messaging.zzd”?
JCIFS SmbFile.exists() and SmbFile.isDirectory() return false when it exists and I can listFiles()
PHP total order
Laravel booking system design
neural net - undefined column selected
How to indicate y axis does not start from 0 in ggplot?
Fragments in backStack
Spinner how to change the data