Create-react-app produces command not found

hey, i’ve just started the ravenous react proj, and i cant install my new react app (“create-react-app ravenous”) in the terminal.

it tells me the the command is not found ("-bash: create-react-app: command not found").

i checked again to verify that the npm is installed globally (which it was).
i checked also npm -v and it showed me “6.9.0”.
and i checked that i’m doing all of that process in an empty new folder i’ve created especially for this particular project.
i use mac and i’ve tried both “sudo-create-react app” & “create -react-app”.

link to the task:

(https://www.codecademy.com/paths/web-development/tracks/front-end-applications-with-react/modules/ravenous-part-one/projects/create-prj-components)

Hi, This is a cool project! You will enjoy this!
Have you run this command?

‘npm install -g create-react-app’

This is in the article just before:
https://www.codecademy.com/paths/web-development/tracks/front-end-applications-with-react/modules/ravenous-part-one/articles/how-to-create-a-react-app

Hi

I’m upping this thread as I’m encountering the same issue but couldn’t find a way to solve it.

I have run the “npm install -g create-react-app” but without the “-g” part, as running it with the -g would give me an access error. The result was the following:

npm WARN deprecated mkdirp@0.5.4: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN saveError ENOENT: no such file or directory, open ‘/Users/alpha/Downloads/Coding/package.json’
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open ‘/Users/alpha/Downloads/Coding/package.json’
npm WARN Coding No description
npm WARN Coding No repository field.
npm WARN Coding No README data
npm WARN Coding No license field.

+ create-react-app@3.4.1
added 99 packages from 47 contributors and audited 193 packages in 6.92s

5 packages are looking for funding

  • run npm fund for details*

found 0 vulnerabilities

So it seems it got installed somehow.
After that, I’ve tried to run “create-react-app projectname” in the terminal but it got me a “-bash: create-react-app: command not found”

Could you help me solving this issue and moving forward in the project?

Thank you very much in advance for your help.

1 Like

But you don’t understand why. Which is a problem. What does the -g flag do? Have you googled?

make sense, given what the consequence is of omitting the -g flag.

the -g flag install the package Globally, so without the the -g flag, the package is installed locally in your project. But the local package is very like not in your path.

Thanks for the fast reply!

I have actually decided to try without the -g, based on an explanation you have given on another thread, and I quote:
" you do understand by now that -g means you want to install the package globally (for all users)? This does require “administrator” privileges indeed.
you can also install the package only for your current user, then you don’t need special permission"

I thought this wouldn’t create new difficulty afterwards, but it did. So the solution to this is to re-install it but globally this time? Is there a way to do so without encountering the first access error I had in the 1st place?

Thanks for your time

Even i keep learning, i would personally check the package website:

https://github.com/facebook/create-react-app

to see what the recommended approach is. Seems to be to use npx

Thank you!
npx seems to fix the problem for now. I’ll spend some time digging into “why” :slight_smile:

what i know (been a while since i used npx) is that npx knows the path of the locally installed packages, making it easier to run the packages.

i think you could use npm as well, but then you get something like:

./node_modules/react/bin/somescript

or something.