In React native yarn start is not working in cmd - react-native

I am new in react native so help me starting with it,
when i type yarn start in cmd it shows me that error
Error: spawn cmd ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
at onErrorNT (internal/child_process.js:468:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I have no idea where i have a problem.

In react native, you have to run the app either on android or ios by running these commands.
react-native run-android
OR
react-native run-ios

Related

Can't build expro project

I would like to create react native project using expo
but get fail.... anyone knows how to solve it???
request to https://registry.npmjs.org/expo-template-blank failed, reason: connect ETIMEDOUT 104.16.16.35:443
but using react-native-cli is work for me, not work with expo...
expo init app
Choose a template: ยป blank a minimal app as clean as an empty canvas
request to https://registry.npmjs.org/expo-template-blank failed, reason: connect ETIMEDOUT 104.16.19.35:443
FetchError: request to https://registry.npmjs.org/expo-template-blank failed, reason: connect ETIMEDOUT 104.16.19.35:443
at ClientRequest.<anonymous> (C:\Users\Me\AppData\Roaming\npm\node_modules\expo-cli\node_modules\minipass-fetch\lib\index.js:97:14)
at ClientRequest.emit (events.js:315:20)
at TLSSocket.socketErrorListener (_http_client.js:469:9)
at TLSSocket.emit (events.js:327:22)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
Finally,I have no idea to run "expo init app" to create project....
so, I go to https://snack.expo.io/
create and download the project.
then go to the project's root directory.
Then use these commands:
npm install -g expo-cli
npm install
expo start
It work fine!

I get 'react-native' is not recognized as an internal or external command when I run "npx react-native init AwesomeProject"

I have installed node and jdk8 using chocolaty.
While I was following the official guide "Setting up the development environment -> React Native ClI Quick start for 'Windows & Android'" I get the following error when I run npx react-native init AwesomeProject command:
'react-native' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code 1
npm ERR! path E:\UOG\React_Native_Projects\MyFirstApp
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c react-native init AwesomeProject
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Muhammad Suleman\AppData\Local\npm-cache\_logs\2021-01-23T09_10_07_360Z-debug.log
Run this command
npm install -g react-native-cli
after that just add your npm path to your system variables in environment variables
C:\Users\YOUR USERNAME\AppData\Roaming\npm
I also have this problem. It got fixed by first typing following command:
npm i react-native
then:
yarn react-native init AwesomeProject
and it worked!!

How to fix package.json to properly run my react app?

I'm having trouble launching my React App. I get the same message:
"npm ERR! missing script: start"
but I do have start in my package.json.

npm ERR! missing script: android

I get several npm ERR! when trying to run : D:\React Native\cleanProject>npm run android
npm ERR! missing script: android
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Roaming\npm-cache_logs\2019-03-26T08_39_44_164Z-debug.log
npm i
D:\React Native\cleanProject>npm run android
npm ERR! missing script: android
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Roaming\npm-cache_logs\2019-03-26T08_39_44_164Z-debug.log
The command that you are trying to run is doesn't exist. Please try to run with this given below command.
react-native run-android
I think you need to run the following command for installing 'react-native' project to your Node JS first.
npm install react-native
After that, also make sure an emulator is started or cell phone is connected with developer mode.
And then retry by running
react-native run-android
to see if you can build and run the your application successfully.
check if your environment variable set properly.
In your PATH Variable:
C:\Users[Username]\AppData\Local\Android\Sdk\platform-tools C:\Users[Username]\AppData\Local\Android\Sdk\tools
C:\Program Files\nodejs
In your system Variable
ANDROID_HOME C:\Users[Username]\AppData\Local\Android\Sdk
JAVA_HOME C:\Program Files\Java\jdk1.8.0_191
Hope it works...
Follow this command, it works for me
npx react-native run-android
make sure you are in the root directory of your app before using react-native run-android
1- open your project and make sure you see the android rectory
2- in the address bar at the top type cmd and a new cmd will open at that location
3- type react-native run-android
I hope it helps

How can i run a demo React Native Code on Phone

Im totally new to React Native and just learned to setup the necessary environments and follow these steps;
Install Node.js
Download Expo client at mobile device
npm install -g create-react-native-app
cd to my desired directory
create-react-native-app some_app_name
cd to my app folder containing default app.js
npm start
basic / empty app will be loaded on my phone and code can be opened using editor of choice.
Now i've downloaded some demo simple apps from github and udemy (with full source code)
I tried to extract the files and cd to the folder and execute "npm start"
However, there is always this error
react-native-scripts: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! demo_app#0.1.0 start: react-native-scripts start
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the demo_app#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
May i know what is missing? How do i get this right?
The command to run a react-native app is react-native run-android for android devices and react-native run-ios for ios devices. Are you sure that you are running these commands to start the app?
Seems like this might be a duplicate of:
sh: react-scripts: command not found after running npm start