nlogn
nlogn

Reputation: 1054

React-native installation issue

Followed the setup steps from official site,I am not able to find react-natve command refer below console commands and its output:

Bhushans-MBP:node_modules bhushanraut$ npm install -g react-native-cli
/Users/bhushanraut/.npm-packages/bin/react-native -> /Users/bhushanraut/.npm-packages/lib/node_modules/react-native-cli/index.js
/Users/bhushanraut/.npm-packages/lib
└── [email protected] 

Bhushans-MBP:node_modules bhushanraut$ react-native init AwesomeProject
-bash: react-native: command not found

Please help me to resolve this.Thanks in advance.

Upvotes: 0

Views: 249

Answers (2)

Vijay Joshua
Vijay Joshua

Reputation: 1

The below steps may be useful for react-native installation if you encounter any problem

Steps followed from the below URL https://shift.infinite.red/getting-started-with-react-native-development-on-windows-90d85a72ae65

npm install -g react-native-cli

react-native init AwesomeProject

cd AwesomeProject/

((if not exist "%USERPROFILE%/.gradle" mkdir "%USERPROFILE%/.gradle") && (echo org.gradle.daemon=true >> "%USERPROFILE%/.gradle/gradle.properties"))

react-native run-android

There was error unable to configure the gradle from @react-native-community/CLI-Platform-android

Hence navigate to AwesomeProject/node_modules, run the below command

npm i @react-native-community/cli-platform-android

Finally build is executed successfully without any error

react-native run-android

In another command prompt start the emulator

C:\Users\tapzu\AppData\Local\Android\Sdk\emulator>emulator -list-avds Nexus_6P_API_28 C:\Users\tapzu\AppData\Local\Android\Sdk\emulator>emulator -avd Nexus_6P_API_28

Upvotes: 0

Jickson
Jickson

Reputation: 5193

The issue is /Users/bhushanraut/.npm-packages/bin/ directory is not added to global PATH variable.

You need add that to PATH variable.

Execute the below command in terminal

vi ~/.bash_profile 

This will open the file in vi editor. Append the following line in that file.

export PATH=$PATH:'/Users/bhushanraut/.npm-packages/bin/'

Then save and close the file.

Execute the following command

source ~/.bash_profile 

Now try executing react-native init AwesomeProject command. This should solve the problem.

Upvotes: 2

Related Questions