0

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!

Jason Procka
  • 135
  • 1
  • 5
  • 12
  • Does this help? http://stackoverflow.com/questions/38751830/create-react-app-installation-error-command-not-found – Dan Abramov Dec 23 '16 at 12:55

5 Answers5

3

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
connelblaze
  • 581
  • 1
  • 7
  • 17
2

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!

Brian Tompsett - 汤莱恩
  • 5,195
  • 62
  • 50
  • 120
B. Suero
  • 21
  • 1
0

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

AmirHossein Rd
  • 353
  • 3
  • 12
0

Add npm-packages to path in you .bash_profile

echo 'export PATH="$HOME/.npm-packages/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
Thermech
  • 3,407
  • 1
  • 35
  • 56
0

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
+ create-react-app@2.1.1
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
user3444999
  • 421
  • 4
  • 9