Reputation: 91
I didn't use react-native for a few months. It looks like some things have changed meanwhile. In the official documentation they recommend to uninstall react-native-cli
and to usenpx react-native init
instead. I did this but ended up with an error because I didn't install that package globally. However, if I install react-native
globally, it results in an error when I run the project, saying that I should remove the global package.
What is the proper way to create a react app nowadays?
Upvotes: 9
Views: 40881
Reputation: 1876
🚨️ The init
command is deprecated for react-native.
Use this (for [email protected]):
npx @react-native-community/cli init projectName
Upvotes: 0
Reputation: 1
AppData\Roaming\npm\node_modules\npm\bin\npx-cli.js' its showing like this error
Upvotes: 0
Reputation: 1
it's easy! in case of developing in windows just do the following command in your prefered terminal with administrative access: npx react-native init YourPrjName
for details take a look at this brief video https://youtu.be/A5pXsiBVKTY
and don't forget to use lower case except for project name
Upvotes: 0
Reputation: 416
npx react-native init ProjectName
to create new projectyarn react-native run-android
or yarn react-native run-ios
to run the project@Raeygzz if you want to use react-native related command add yarn/npx in the beginning of the command
yarn react-native run-android
yarn react-native run-ios
or
npx react-native run-android
npx react-native run-ios
if you want to create apk debug use in your root project
cd android && gradlew assembleDebug
apk release in your root project
cd android && gradlew assembleRelease
Debug with bundle in your root project
yarn react native run-android
and get the apk file in
android\app\build\outputs\apk\debug
i usually do this if the device i working on doesn't have an usb cable, so i copy the file there, and sent it to the cloud, download it to device and install it, after that i just shake the phone and go to settings and setup debug server ex: 10.xxx.xxx:8081 then run yarn start in cmd shake the device and choose refresh
the difference is here between react-native run-android and gradlew assembleDebug react-native run-android Vs ./gradlew assembleDebug
Upvotes: 17
Reputation: 1
Try to use npx react-native init projectName
then change directory to project with cd projectName
and run the project with react-native run-android
Upvotes: 0
Reputation: 61
Thanks @Gus Nando for the detail... and if i want to make a debug build for android using npx then what should i follow. And also if there is any changes or change in set of way to create debug as well as production build for both android and ios platform.
Any kind of info related to npx will be of much help. Thanks in advance
Upvotes: 0
Reputation: 590
The first thing you need to do is delete react-native-cli:
npm uninstall react-native-cli
or npm uninstall --global react-native-cli
Then, install Expo CLI if you have NodeJS 10 LTS or greater installed:
npm install -g expo-cli
You should be able to make new react native app now with expo-cli like that :
expo init ProjectName
Expo is a tool that allows you to set up a development environment on your phone. For more information, see the documentation here: https://expo.io/
It is the most efficient and fastest way to develop, test and deploy an application
Upvotes: 1