Create-React-App, Installation Error ("Command Not Found")

I have installed create-react-app exactly as instructed on the facebook instruction page ():

First, install the global package:

npm install -g create-react-app

I did this. It appeared to work fine - the file was installed to

users/*name*/.node_modules_global/lib/node_modules/create-react-app

I'm not really sure why global install takes it to this path, but there you have it.

Next instruction:

Now you can use it to create a new app:

create-react-app hello-world

Couldn't be simpler, right? But Terminal spits out this at me:

-bash: create-react-app: command not found

It's probably something very simple I'm missing but I don't really know where to look. If anyone can help I'd really appreciate it!

Thanks in advance.

Note: I'm using Node v6.3.1, and npm v3.10.3

12 Answers

You are able to apply the following solution:

$ npm config set prefix /usr/local
$ sudo npm install -g create-react-app
$ create-react-app my-app
4

The environment variables are not set properly. When you run the create-react-app it shows you a path along with the error. Copy that path and add it in the environment variable.

Alternatively you can use the command:

npx create-react-app <app_name>.

This will do the work for you.

0

Your Node setup looks incorrect. It's not an issue with Create React App—it seems like you can't run any global Node commands.

It looks like ~/.node_modules_global/bin is not in your PATH environment variable so it can't execute global commands. That's just how Bash works—it can't guess where the command lies, you need to tell it. I would assume Node installation should do this by default but it depends on how you installed Node.

So make sure that directory is in your PATH and try again. If you use Bash, add this to your .profile and then restart the Terminal:

export PATH=$HOME/.node_modules_global/bin:$PATH
11

Try this. It worked or me. I found this in the React documentation. "Npx" is not a typo. It's a package runner tool that comes with npm 5.2+.

npx create-react-app my-app

0

In 2020 Dec 17

Install Nodejs & npm

sudo apt update
sudo apt install nodejs
sudo apt install npm

if you install maybe show you this like errors for Reactjs setup.this helpful for you

npm install -g create-react-app


npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/create-react-app
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/create-react-app'
npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/create-react-app'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/lib/node_modules/create-react-app'
npm ERR! }
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.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/user/.npm/_logs/2020-12-17T14_16_02_442Z-debug.log

then When you type after this

create-react-app test-react-app 

Show you in terminal zsh: command not found: create-react-app

you fix this error by using this command

sudo npm install -g create-react-app
create-react-app test-react-app

I hope work fine for you also.

Use npx instead of npm.

Check this out->

Answers given above are right but I want to share some things that I also faced and these are basics.

To setup react project

If you want to create a node environment

$ sudo apt-get update
$ sudo apt-get install nodejs

(Sometimes we can also run without sudo; but sudo means install in system level.)

$ sudo apt-get install nodeenv

$ nodeenv env
$ source /bin/activate

If you want to create new react app then

$ npm install create-react-app

If an error occurs create-react-app: command not found then install with -g, it happens because node is installed globally and it is not getting the node in local

$ npm install -g create-react-app

$ create-react-app app_name
$ cd app_name
app_name$ npm start

I hope you already installed Node package manager(npm). now run npm install -g create-react-app, if everything fine then you can use create-ract-app command. if you are getting any permission error just sudo npm install -g create-react-app.

I hope it will work. Happy Hacking.

if you face following this problem:

create-react-app: command not found

solution:

  sudo npx create-react-app react_spa
  cd react_spa
  sudo npm start

I hope its work.

This is how I get it fixed.

  1. Step # 1:- Make sure, Node js and React js is installed globally. You can check Nodejs by node --version . If not installed, install and run export PATH=$HOME/.node_modules_global/bin:$PATH
  2. Step # 2:- Clean your npm cache by following the command npm cache clean --force
  3. run sudo npx create-react-app your-app-name

And that's it. you're done.

Please note, This solution worked for me for MAC OS

I tried all methods listed above and in other sites. They weren't working for me. But for some reason I decided to add the create-react-app directory into my system variables as a last ditch method and to my surprise this actually worked.

If above answers are not working, then try this

  1. update the npm version (npm install npm@latest -g)
  2. clear the cache (npm cache clean --force)
  3. create the react project (npx create-react-app myapp) (while running the 3rd command, make sure that create-react-app is already installed in the pc)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest