How can i run a demo React Native Code on Phone - react-native

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

Related

Unable to update or execute the 'expo' command in command prompt

For the first time i tried to install the expo-cli on my project directory it worked. I can use expo init to make my first react native app in my command prompt, and run the app with expo start. But now when i have some new project to make with the 'expo' command like expo init or expo start or something else, it didn't work anymore. When i tried to type and enter the expo command, its always be
'expo' is not recognized as an internal or external command, operable program or batch file.
And now when i tried to update the expo-cli with npm install -g expo-cli a warning of error appeared.
npm ERR! code EPERM
npm ERR! syscall rename
npm ERR! path C:\Users\ACER\AppData\Roaming\npm\node_modules\expo-cli
npm ERR! dest C:\Users\ACER\AppData\Roaming\npm\node_modules\.expo-cli-foqoNR8w
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\ACER\AppData\Roaming\npm\node_modules\expo-cli' -> 'C:\Users\ACER\AppData\Roaming\npm\node_modules\.expo-cli-foqoNR8w'
npm ERR! [Error: EPERM: operation not permitted, rename 'C:\Users\ACER\AppData\Roaming\npm\node_modules\expo-cli' -> 'C:\Users\ACER\AppData\Roaming\npm\node_modules\.expo-cli-foqoNR8w'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'rename',
npm ERR! path: 'C:\\Users\\ACER\\AppData\\Roaming\\npm\\node_modules\\expo-cli',
npm ERR! dest: 'C:\\Users\\ACER\\AppData\\Roaming\\npm\\node_modules\\.expo-cli-foqoNR8w'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ACER\AppData\Local\npm-cache\_logs\2021-01-10T17_18_03_575Z-debug.log
This preventing me from doing the installation of react navigation and make a new project by using 'expo' command. And i've been search this problem on and tried to solve it but it didn't work on any various ways that i've tried. I've tried to reinstall the expo-cli but it didn't work, i've tried to use yarn as well but still it didn't work. I've been re-added the path for the npm and even tried to reinstall nodejs and use any various code for updating and installing the 'expo-cli' but it didn't work as expected.
Any suggest on how do i can fix this problem ?
Run your command line as Admin and then do the following:
npm remove -g expo-cli to remove the existing CLI
and then npm i -g expo-cli to reinstall the Expo CLI.
Then you can simply login via expo login (if you were logged in) and take off from where you were!
I delete the expo file on the path :
C:\Users\ACER\AppData\Roaming\npm\node_modules\expo-cli
C:\Users\ACER\AppData\Roaming\npm\node_modules\.expo-cli-foqoNR8w
the file that i deleted : expo-cli & .expo-cli-foqoNR8w
And then try to install the expo-cli again with npm install --global expo-cli then it work. Now i can use my expo start or whatever code with 'expo' in it. And also now i can install react navigation on my project directory. And i'm running the installation by using command prompt run as admin.

The NativeScript Plugin Seed Demo Does Not Run

We are trying to use our native codes in Nativescript therefore we tried to test nativeScript plugin seed. We follow the steps to in README however demo does not run and stops.
We tried all available version we could reach and applied the flow we see in guidance videos.
Last section of terminal messages:
Webpack compilation complete. Watching for file changes. Webpack build
done! Copying template files... Unable to apply changes on device:
F2CB7B69-FE7F-4EE7-9150-133E604FBF18. Error is: zlib: unexpected end
of file. npm ERR! code ELIFECYCLE npm ERR! errno 134 npm ERR!
nativescript-tstpin#1.0.0 demo.ios: npm run tsc && cd ../demo && tns
run ios --syncAllFiles --emulator npm ERR! Exit status 134 npm ERR!
npm ERR! Failed at the nativescript-tstpin#1.0.0 demo.ios script. npm
ERR! This is probably not a problem with npm. There is likely
additional logging output above.
npm ERR! A complete log of this run can be found in: npm ERR!
/Users/hasanguner/.npm/_logs/2019-05-22T08_53_09_212Z-debug.log
Hasans-MacBook-Pro:src hasanguner$
After the messages in the terminal it stops. It would be great if anyone could help how to step over this starting point.
Solved. I tried the following: On Mac:
sudo npm cache clean --force
Then worked fine.
If anyone tells me the reason it would be perfect.

Cannot start Electron application - missing package.json

I'm currently doing a Python project where I want to display my results in an Electron application. I have seen a demo video on YouTube on how to set up Electron on a Mac. The video showed 3 simple steps to be executed in the terminal:
git clone https://github.com/electron/electron-quick-start
cd electron-quick-start
npm install && npm start
When I first ran the above commands it worked fine for me. I was able to start the Electron application.
But when I tried to re-start the application using the command npm start after going into the electron-quick-start directory, I am not able to open the application.
I am continuously getting an error message as follows:
(base) Viveks-MacBook-Pro:electron-quick-start vivekchowdary$ npm start
npm ERR! path /Users/vivekchowdary/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/Users/vivekchowdary/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/vivekchowdary/.npm/_logs/2019-04-19T12_55_01_157Z-debug.log
(base) Viveks-MacBook-Pro:electron-quick-start vivekchowdary$
I don't know what it means? But I just want to open the Electron application.
As the error message states, the file package.json cannot be found.
One possible reason is that the terminal is not in the correct project folder and that you need to cd into the folder before running npm start.
If you cd to any folder that has no package.json (and whose parent folders don't have a package.json) and run npm start, you'll be presented with this error message.
Your specific file path seems to indicate that you ran npm start from your home folder, not the project folder that contains package.json.
I got a similar issue and I fixed it by creating the files it was asking for as well as a basic package.json file that my compiler generated for me

Alternative on "npm run eject"

Will a ReactJS app project be ended when I simply close the CLI, while in first instance the Node.js Package Manager was running the developer server through the "npm start"-command in the CLI? Or will the ReactJS app project run in the background?
If the second question is true, how can I otherwise stop the ReactJS app project without having to worry that I have to run "npm run eject" in the CLI and never being able to run the ReactJS app project in the development stage? The following occurs when I do so (run "npm run eject" in the CLI) for the second time:
npm ERR! path C:\Users\1st assembled M-PC\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\1st assembled M-PC\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\1st assembled M-PC\AppData\Roaming\npm-cache\_logs\2018-04-27T17_27_41_529Z-debug.log
If your app is running simply press Control + C to halt it. Closing the Command Prompt will achieve the same result. You will still be able to run it again with npm run start after this.
A note on ejecting – to successfully eject you need to run npm run eject from your project folder. However this operation is usually needed only if you are a power user and you aren't happy with the default configuration.

Not able to eject again after eject react native

I am new to reactnative, I have successfully eject to a native build, and I found some thing to tweak after reactnative so I want to edit the js again and eject again.
But I found it not able to eject using npm run eject again and it shows the following error:
npm run eject
npm ERR! Darwin 16.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "eject"
npm ERR! node v6.11.0
npm ERR! npm v3.10.10
npm ERR! missing script: eject
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /Users/xxx/work/reactnative/maoquote/npm-debug.log
And I checked the package.json in the project folder, and the eject block was missing, but I am sure that the eject block was there before I first ejection the project, seems the framework has removed it after ejection?
Don't know why reactnative not allow me to eject again, is there any way I could do that?
I am using reactnative version 0.45
thanks !
You created the project using create-react-native-app ? Unfortunately, ejecting is not reversible, you should use your version control to manual roll back.
See Ejecting:
"Ejecting" is the process of setting up your own custom builds for
your CRNA app. It can be necessary to do if you have needs that aren't
covered by CRNA, but please note that aside from the use of version
control systems (git, hg, etc.) it is not reversible.