Installation Error create-react-app

I ran into issues during the installation I was using
npx create-react-app my-app cd my-app npm start

as suggested in

All I did was
npx create-react-app my-app
but the error I got from terminal was

Qubes-MacBook-Pro:~ qube$ pwd
Qubes-MacBook-Pro:~ qube$ ls
Applications		Desktop			Downloads		Movies			NetBeansProjects	Postman			apache-maven-3.6.1	docker			package-lock.json
Books			Documents		Library			Music			Pictures		Public			apache-tomcat-8.5.11	node_modules
Qubes-MacBook-Pro:~ qube$ npx create-react-app my-app
npm ERR! path /Users/qube/.npm/_cacache/index-v5/4c/c4
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir
npm ERR! Error: EACCES: permission denied, mkdir '/Users/qube/.npm/_cacache/index-v5/4c/c4'
npm ERR!  { [Error: EACCES: permission denied, mkdir '/Users/qube/.npm/_cacache/index-v5/4c/c4']
npm ERR!   cause:
npm ERR!    { Error: EACCES: permission denied, mkdir '/Users/qube/.npm/_cacache/index-v5/4c/c4'
npm ERR!      errno: -13,
npm ERR!      code: 'EACCES',
npm ERR!      syscall: 'mkdir',
npm ERR!      path: '/Users/qube/.npm/_cacache/index-v5/4c/c4' },
npm ERR!   isOperational: true,
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, mkdir \'/Users/qube/.npm/_cacache/index-v5/4c/c4\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/Users/qube/.npm/_cacache/index-v5/4c/c4',
npm ERR!   parent: 'external-editor' }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/qube/.npm/_logs/2019-12-22T01_29_40_120Z-debug.log
Install for create-react-app@latest failed with code 243

I tried looking for a fix but it suggested to use
sudo chown -R $USER /usr/local/lib/node_modules

Is there anyone that ran into this issue or know how to fix this issue?

it? who? certainly not npm, it even advises against it in your error message (and it is not appropriate)
In any case, that’s not the directory that the error message mentions, so it wouldn’t matter. So the first step would be to read the error message, what does it say is wrong? It mentions a directory. Which? Should you have permission to do that? If you should have permission but don’t, then what happened? Were you using sudo previously to mess up your permissions? That’d be my first guess.

when you get permission denied that’s usually saying you’re doing it wrong. doing it wrong with admin isn’t less wrong, it’s more wrong. so instead of forcing the wrong thing, reconsider and then do the right thing, typically using a different location where you already have permission

since the directory mentioned is something you should have write access to, that implies your permissions are messed up, you’d need to undo that. ~/.npm probably doesn’t contain anything you care about (packages that are easily re-obtained), so if you delete it you’ll also be getting rid of anything in it that has bad permissions set to it. since they have bad permissions set to them you’ll probably need to use sudo to get rid of it, and after that you probably don’t want to use sudo for anything else.

this “advice” probably has to do with npm install’s -g flag for installing things globally. the default location is system owned which means, no, that’s not where they should go. instead, what should be done is to specify an appropriate location to put things that don’t belong to projects

I found out that I was doing it in an area I probably shouldn’t have I didn’t use sudo I ended up doing
npx create-react-app
in a directory I want to build the app in. It didn’t really explain that in the instructions well and someone that replied to me said to just use the command on any directory and it wouldn’t hurt that’s why I got that error. I ended up making a new directory on desktop and it worked :smiley:

2 posts were split to a new topic: Installation Error create react app