13

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
└── react-native-cli@1.0.0

Looks like install.

After that I tried

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

What could be the problem

Damathryx
  • 2,706
  • 3
  • 25
  • 48
Mahavir
  • 771
  • 3
  • 9
  • 23

4 Answers4

11

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!

vijay
  • 10,276
  • 11
  • 64
  • 79
Hussam Kurd
  • 8,066
  • 2
  • 43
  • 38
  • You may want to use `"$HOME/.npm-packages/bin:$PATH"` instead; it’ll work with any user home directory. – bfontaine Jun 06 '18 at 08:49
6

Make sure that /usr/local/share/npm/bin is in your PATH to use binaries installed with npm

Add the following line to your ~/.bashrc

export PATH="/usr/local/share/npm/bin:$PATH"

Then reload your shell session and try that again

LuisPinto
  • 1,667
  • 1
  • 17
  • 36
3
sudo yarn global add expo-cli

sudo yarn global add react-native-cli

You must use sudo here.

brunorey
  • 2,135
  • 1
  • 18
  • 26
0

when you are using the latest version of node js and others related to react native

they updated to run react native app

npx react-native run-android npx react-native run-ios

You can check Here

Bhavin Parghi
  • 132
  • 10