create-react-app not currently working

5.9k views Asked by At

I've ran npm install create-react-app -g and then

create-react-app hello-world

returns

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

I understand that my $PATH is currently messed up. Here's what is returned from echo $PATH

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

I really don't know what to set this as, as I'm currently very new to the terminal. Any help would be greatly appreciated. Thank you!

5

There are 5 answers

0
AmirHossein Rd On

Im not 100% sure on the answer to your question. However; if you are simply trying to setup a react environment, I suggest referring to a Youtube tutorial on React. Create a folder on your desired directory then go to specific directory using Command prompt, or gitBash, or Cygwin and using NodeJs you can install everything you need to get started.Follow the first 10 min to set it up and then you're good to go. Good luck

https://www.youtube.com/watch?v=IR6smI_YJDE&t=278s&list=PLbeWHDJFd79RXvAeGaDXMmxL_tkb3MvdH&index=1

0
user3444999 On

I had same issue, although long term fix to get your $PATH fixed, but I can give you "quick and dirty" way to get your create-react-app started.

This is the output I got after install create-react-app and I used the path to use the command

BatMan-MacBook-Pro:coursera-react batman$ sudo npm install -g create-react-app

/Users/batman/.npm-packages/bin/create-react-app -> /Users/batman/.npm-packages/lib/node_modules/create-react-app/index.js
+ [email protected]
updated 1 package in 2.594s

And I used the path from above to get it going and it worked.

BatMan-MacBook-Pro:coursera-react batman$ /Users/batman/.npm-packages/bin/create-react-app BatManCafe
0
connelblaze On

Just export path to .bashrc and then call it from .profile file all in $Home directory then restart. e.g: .bashrc file:

export PATH=$HOME/node_modules/.bin/:$PATH

.profile file:

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
       . "$HOME/.bashrc"
    fi
fi

 # set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi
0
Thermech On

Add npm-packages to path in you .bash_profile

echo 'export PATH="$HOME/.npm-packages/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
0
B. Suero On

So I have been having this problem recently and it was because I was just typing create-react-app [app-name].

If anyone runs into this problem again instead type npx create-react-app [app-name], npm init react-app [app-name] or yarn create react-app [app-name].

https://facebook.github.io/create-react-app/docs/getting-started

Hope that helps someone!