0

I'm trying to run a new react native project but I'm getting the same problem over and over:
-bash: react-native: command not found.

I tried to solve the problem trough other post like this: react-native: command not found But I'm still getting the same error.

I followed all the steps provided by the React Native page (https://facebook.github.io/react-native/docs/getting-started), and I ended up with these info:

1 npm  -version         6.4.1
2 brew -version         Homebrew 2.1.1
3 brew info watchman    stable 4.9.0 
4 brew info node        stable 12.1.0
5 echo $PATH:

/Library/Frameworks/Python.framework/Versions/3.7/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/(myname)/Library/Android/sdk/emulator:/Users/(myname)/Library/Android/sdk/tools:/Users/(myname)/Library/Android/sdk/tools/bin:/Users/(myname)/Library/Android/sdk/platform-tools:/Users/(myname)/Library/Android/sdk/tools/bin

if I type in: npm install -g react-native-cli

I get:

/Users/(myname)/.npm-global/bin/react-native -> /Users/(myname)/.npm-global/lib/node_modules/react-native-cli/index.js
+ react-native-cli@2.0.1
updated 1 package in 3.653s

Ed Morton
  • 188,023
  • 17
  • 78
  • 185
  • This looks exactly like the situation in the question you linked to. If you really tried all the answers there, please [edit] your question to show how each of them failed. (That is to say, I'm pretty sure you'll find the answer there. And we can't walk you through trying them all.) – tripleee May 05 '19 at 19:39

1 Answers1

0

command not found means exactly that - the command you tried to execute (react-native) isn't found in any of the directories listed in your PATH variable.

Figure out where react-native is installed and either call it with a full path to the executable or add the directory to your PATH.

Based on this from your question:

5 echo $PATH:
/Library/Frameworks/Python.framework/Versions/3.7/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/(myname)/Library/Android/sdk/emulator:/Users/(myname)/Library/Android/sdk/tools:/Users/(myname)/Library/Android/sdk/tools/bin:/Users/(myname)/Library/Android/sdk/platform-tools:/Users/(myname)/Library/Android/sdk/tools/bin

My best guess is that during installation you were following instructions that said to put (myname) somewhere and you literally entered the string (myname) instead of entering your actual login name.

Ed Morton
  • 188,023
  • 17
  • 78
  • 185
  • They probably did it for some sort of anonymity - it's in the `npm install` output too. – tripleee May 05 '19 at 19:40
  • Yes, the issue was the one you pointed out: react-native for some reason wasn't installed in my PATH. So what I did is I figured out in which path react-native was installed and after that trough the "eport" command I added that path to the "home" one. There is another problem: the terminal doesn't remember that.. every time I opn the terminal I have to do the same operation in order to run react native.. any suggestions? – Chilledcow_ May 06 '19 at 16:14
  • Put it in your .bashrc or .bash_profile or whatever "." file executes on your machine when you log in or start a shell as necessary. – Ed Morton May 06 '19 at 16:33