Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React native command not found

I am starting to install react native. I had successfully installed homebrew, nodejs , npm. but not able to install react native

First I had tried

npm install -g react-native-cli

gives me write warning:

Missing write access to /Users/project/.npm-packages/lib/node_modules/react-native-cli

After that I had tried

sudo npm install -g react-native-cli
/Users/project/.npm-packages/bin/react-native -> /Users/project/.npm-packages/lib/node_modules/react-native-cli/index.js
/Users/project/.npm-packages/lib
└── [email protected]

Looks like install.

After that I tried

react-native init AwesomeProject
Error : react-native: command not found

What could be the problem

like image 217
Mahavir Avatar asked Aug 03 '16 08:08

Mahavir


2 Answers

First of all, you have to install react native globally

npm install -g react-native-cli

then it will show you the path for the react native like the following

/Users/{yourUser}/.npm-packages/bin/react-native -> /Users/{yourUser}/.npm-packages/lib/node_modules/react-native-cli/index.js

Then you have to set the default path from the above result and execute the following command

export PATH="/Users/{yourUser}/.npm-packages/bin/:$PATH"

Then reload you session/env vairables

source ~/.bash_profile

It will work like charm!

like image 121
Hussam Kurd Avatar answered Sep 22 '22 02:09

Hussam Kurd


sudo yarn global add expo-cli

sudo yarn global add react-native-cli

You must use sudo here.

like image 24
Hassan Alattas Avatar answered Sep 22 '22 02:09

Hassan Alattas