not able to run react-native project android version - android

react-native run-android shows 
env: sh\r: No such file or directory

try to clean and rebuild your project
react-native start --reset-cache
cd android
gradlew clean
gradlew assembleDebug
or you can simply reinstall npm modues

See if you've done this.
npm install -g react-native-cli
react-native init yourproject
cd yourproject && react-native run-android

Related

Unable to resolve module `./Linking/Linking` from `node_modules/expo/build/ExpoLazy.js`

Has anyone experience this error with expo, when running react-native run-android?
error: bundling failed: Error: Unable to resolve module `./Linking/Linking` from `node_modules/expo/build/ExpoLazy.js`:
None of these files exist:
* node_modules/expo/build/Linking/Linking(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
* node_modules/expo/build/Linking/Linking/index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
"expo": "^37.0.9",
Just ran into this issue, downgrade to 37.0.8 (no caret) and do an npm i. Looks like they released 37.0.9 yesterday and it has an issue.
What worked for me:
1) In package.json change to "expo": "37.0.8"
2) Delete your node_modules
3) installl packages npm i
4) clean cache in expo expo r -c
Now it started to work again. Couldn't find the last step in previous comments.
This is an Internal bug of react-native. You don't have much of a choice, as user3916570 consider downgrading.
For now, downgrading Expo to 37.0.8 fixed this. To downgrade, in your package.json, change your Expo dependency to:
"expo": "37.0.8",
Then remove your node_modules and reinstall everything:
rm -rf node_modules
npm i
It's not an expo version problem only, you should also check the global expo-cli version and probably node as well.
Run:
$ npm install -g expo-cli --force
$ rm -rf node_modules/
$ rm -rf package-lock.json
# (in my case mac '$ brew upgrade node && npm install -g npm')
$ npm install
$ npm run

react-native android error Failed to install the app native_modules.gradle' line: 170 [duplicate]

This question already has answers here:
react-native run-android fails from terminal
(9 answers)
Closed 2 years ago.
running react-native run-android in windows but get this error:
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
:ReactNative:Unexpected empty result of running 'npx --quiet --no-install react-native config' command from 'null' directory.
:ReactNative:Running 'npx --quiet --no-install react-native config' command from 'null' directory failed.
FAILURE: Build failed with an exception.
Where:
Script '/node_modules/#react-native-community/cli-platform-android/native_modules.gradle' line: 170
What went wrong:
A problem occurred evaluating script.
Command config unrecognized. Make sure that you have run npm install and that you are inside a react-native project.
Try running (inside android folder)
./gradlew clean
and then run
react-native run-android
This problem occurred when I was using the latest react-native package "0.61.5" ... I solved it by performing some steps
Removed node_modules
Install npm
npm install npm
or
npm install npm#latest
And Install react-native
npm install --save react-native
Add this to gradle.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
and add this to gradle.wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
then run react-native run-android
This problem occurred when i was using latest react native package "0.61.5" ...
I solved it by changing react native package to "0.61.4"
Go to package.json file
change the version of react native
"dependencies": {
"react": "16.9.0",
"react-native": "0.61.4"
}
and do
npm install
Simply install yarn by the command
yarn install
This happens when you pull code from the repository having npm installed libararies and you are running by yarn

React-Native install on Windows Machine not finding $PATH

I'm installing react-native first y installing react-native-cli
Based on the instructions at: https://facebook.github.io/react-native/docs/getting-started.html...
I installed Android Studio and then added the sdk path to my $PATH, so if I echo $PATH, the path
/c/Users/MyUser/AppData/Local/Android/Sdk/platform-tools
is included. Then I...
npm install -g react-native-cli
which resulted in
C:\Users\MyUser\AppData\Roaming\npm\react-native ->
C:\Users\MyUser\AppData\Roaming\npm\node_modules\react-native-cli\index.js
+ react-native-cli#2.0.1
updated 1 package in 2.303s
but it is still not finding react-native ...
react-native-cli --version
bash: react-native-cli: command not found
Why can't I find my react-native-install?
react-native-cli is not a command. With this npm i -g react-native-cli you can use the command -> react-native
you can now use react-native init "project"
then npm start

How do I create a React Native project using Yarn?

I am running the following commands in the DOS console on a Windows 7 (64-bit) machine.
npm install -g yarn
yarn add global react-native
yarn add global react-native-cli
react-native init sample
After running react-native init sample, the console was closed.
The error log shows:
D:\Mobile>"$basedir/../../Users/pramaswamy/AppData/Local/Yarn/.global/node_modules/.bin/react-native.cmd" "$#"
D:\Mobile>exit $?
I think you're adding global dependencies wrong, and you shouldn't need to install react-native, globally or locally. react-native init will create a package.json with react-native listed as a dependency.
You should be able to install react-native-cli globally with yarn global add react-native-cli, not yarn add global react-native-cli.
Here yarn run android command will be used to run the react native app using yarn package manager, and yarn start will start the node JS server.
You should be fine with running the following:
npm install -g yarn
yarn global add react-native-cli
react-native init sample
yarn run android
yarn start
NEW SEP 2019,
now it's more simple, use node10 and expo: (easy way)
npm install -g expo-cli
*to create project:
expo init AwesomeProject
cd AwesomeProject
npm start
*install the app 'expo' on your phone, and scan the qr code for the project and you can start to view your app
more info:
https://facebook.github.io/react-native/docs/getting-started.html
UPDATE OCT 2018 Create React Native App (now discontinued) has been merged with Expo CLI
You can now use expo init to create your project. See Quick Start in
the Expo documentation for instructions on getting started using Expo
CLI.
Unfortunately, react-native-cli is outdated. Starting 13 March 2017, use create-react-native-app instead. Moreover, you shouldn't install Yarn with NPM. Instead, use one of the methods on the yarn installation page.
1. Install yarn
Via NPM. According to its installation docs, you shouldn't install yarn via npm, but if necessary, you can still install it with a pre-v5 version of npm.
UPDATE 2018 - OCTOBER
Node 8.12.0 and NPM 6.4.1 is already compatible with create-react-native-app. Really some minors previous versions too. You don't need more downgrade your npm.
On Ubuntu.
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
On macOS, use Homebrew or MacPorts.
brew install yarn
sudo port install yarn
2. Install the Create React Native App
yarn global add create-react-native-app
3. Update your shell environment
source ~/.bashrc
4. Create a React native project
create-react-native-app myreactproj
You got the order wrong. You should be
yarn add global react-native-cli
yarn add react-native
react-native init sample
Please You visit Bug
yarn global add react-native-cli
with
react-native --version
and I get "$basedir/../../Users/juvasquezg/AppData/Local/Yarn/config/global/node_modules/.bin/react-native.cmd" "$#"
the system cannot find the path specified
Go to C:\Program Files\nodejs and I saw:
react-native
react-native.cmd
react-native.cmd.cmd
The fix is to delete react-native.cmd and rename react-native.cmd.cmd to react-native.cmd
The Solution #1324 (comment)
You could also do
yarn dlx expo-cli
then:
expo init project_name
and follow the instructions
after finishing cd project_name and try
yarn web
It is now:
yarn dlx create-react-native-app
then follow the instructions.
cd project_name into the project folder and do:
yarn install
then try with:
yarn web
If you want to create app using yarn instead of npx;
yarn dlx react-native init ExampleApp this command will be helpful.
According to the react native documentation we should use npx react-native init AwesomeProject command
For more info about "yarn dlx": https://yarnpkg.com/cli/dlx
Yarn global is deprecated. If you run yarn global you will get an error.
Usage Error: The 'yarn global' commands have been removed in 2.x -
consider using 'yarn dlx' or a third-party plugin instead
But yarn dlx won't work like yarn global or npm install <module> --global

react-native run-android is unrecognized

I've installed react-native-cli globally:
npm install -g react-native-cli
Then run:
react-native init AwesomeProject
cd AwesomeProject
I got the following structure:
-- AwesomeProject
---- node_modules
------ react-native
When I run react-native run-android I get an error:
Command run-android unrecognized. Did you mean to run this inside a react-native project?
When I run react-native start I get the same.
react-native -v
prints:
react-native-cli: 0.2.0
react-native: n/a - not inside a React Native project directory
What I'm doing wrong?
the answer is easy nad it is not because of any bug at all.
make sure you are in correct directory
if in current directory there is not any react native app ,it gives you this error
What caused this for me was running npm install --save [package] when actually the system has previously been using yarn instead of npm.
To solve this I just deleted the node_modules folder and ran: yarn install and after that react-native run-ios (or android) works fine.
(This is a duplicate of React Native: Command `run-ios` unrecognized)
I just ran "yarn" with no arguments and it fixed it.
Please try this command:
npm install --save react-native
The problem was that I terminated init command because it looked like hanged without errors (even 24 hours later). To fix this I updated nodejs and npm to newer versions. Once I have done it react-native init was executed properly and there is no more problem with react-native run-android.
react-native run-android is unrecognized
Make sure that you have installed npm or use
in your project directory
npm install
you have to update your npm.
To do that
npm install npm#latest -g
try "yarn install".
It will install the missing files in node_modules
It worked for me
This can be caused by a couple of issues.
!!! Before trying each solution remember to open a new terminal since you might have old paths sources from your .bashrc file. !!!
You did not install the contents of the project. In order to solve this you have to install the node_modules by typing:
npm install or yarn install
You are coming back to a previously installed project after doing some funny things with your react-native installation and global configurations. (Upgrading the library, upgrading node doing something with globally installed node_modules).
You should clean all your caches and project modules
Here you can find a command to do all these things in one line (remember to replace npm with yarn accordingly):
https://gist.github.com/jarretmoses/c2e4786fd342b3444f3bc6beff32098d
Your global installation of react-native or react-native-cli is broken. In this case simply reinstall your libraries globally.
npm: npm install -g react-native && npm install -g #react-native-community/cli
yarn: yarn global add react-native && yarn global add #react-native-community/cli
I think the command you are looking for is react-native run-android.
cd into your project and run this command where all you js files are present and not in the android folder.
It will run a package manager, do not close that. Also you need to have an emulator or a device connected to your computer with usb debugging enabled.
Hope the answer helped
npx react-native run-android
Use of npx will pick local npm node_modules directory
Do npm install then run react-native run-android
Make sure you go into the directory having package.json
If you have deleted nodemodules try "npm install".
And don't forget the "init" in "react-native init MyApp". "init"
initializes the package.json.
Step 01 : Make sure that you are in right directory
Step 02 : npm install run this command
Step 03 : npm audit fix run this to fix issues
Try deleting node_modules folder and then run the commands again
You can solve this by yarn or npx:
yarn react-native run-android
npx react-native run-android
Everything has already tried like me? Then try again once "Yarn install after deleting node_modules". It worked for me.
I did everything correct while setting up, but was unable to run the android code. Just make sure while running the command react-native run-android that, you are inside the AwesomeProject folder created by the react-native init AwesomeProject command.
The folder by default for my PC was under C:\Windows\system32\AwesomeProject in Windows.
Hope it helped for the first timers :)
You need to update the project with the latest version of react-native. Just run this command.
npm install --save react-native#latest
If you guys have latest react native version and facing this error
"UNRECOGNIZED COMMAND run-android".
then run follow these steps it will definitely help you.
Step: 1 -> create a new file "react-native.config.js" in the project root directory.
Step : 2 -> Inside "package.json" you have "assets" array inside "rnpm" object cut these assets from this and paste in your "react-native.config.js".
i-e:
module.exports = {
assets: ['./assets/fonts'],
}
Step : 3 -> Remove "rnpm" object from "package.json".
Step : 4 -> Replace your "scripts" with below mentioned "scripts" inside "package.json"
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"android": "react-native run-android",
"ios": "react-native run-ios",
"lint": "eslint .",
"android:prod": "npx react-native run-android --variant=release",
"ios:prod": "react-native run-ios --configuration Release"
}
That's it
Happy Hacking..............
Uninstall react-native from global
$ npm uninstall -g react-native
Then
Install react-native to global
$ npm install -g react-native-cli
That worked for me
react-native run-android
start [options] starts the webserver
run-ios [options] builds your app and starts it on iOS simulator
run-android [options] builds your app and starts it on a connected Android emulator or device
new-library [options] generates a native library bridge
bundle [options] builds the javascript bundle for offline use
unbundle [options] builds javascript as "unbundle" for offline use
eject [options] Re-create the iOS and Android folders and native code
link [options] [packageName] links all native dependencies (updates native build files)
unlink [options] <packageName> unlink native dependency
install [options] <packageName> install and link native dependencies
uninstall [options] <packageName> uninstall and unlink native dependencies
upgrade [options] upgrade your app's template files to the latest version; run this after updating the react-native version in your package.json and running npm install
log-android [options] starts adb logcat
log-ios [options] starts iOS device syslog tail
dependencies [options] lists dependencies
info [options] Get relevant version info about OS, toolchain and libraries
They have made some unnoticeable changes. For instance run-android(now) run android(before).
Try to delete "package-lock.json" and re-run "npm install", then try your command, It should work
I got this error because I had parenthesis in the path "(" and ")". Possibly this error is thrown for other special characters as well.
Ensure you run the command in the projects' terminal, preferably the Android IDE. Run the adb devices to know your active devices as well
If your package.json file is containing any comment then this error is comes. So remove all comments from package.json and then run command it will work.
Also try to run command npm install --save then it will log if other error there. If any others error also there, then first fix it and then run command it will work.
In Android Studio click in Tools -> SDK Manager -> in System Settings click in Android SDK -> choose tab SDK Tools, then enable Android SDK command line tools (lasted).
It work for me!
Open your React Native Project Root Directory and locate android -> app -> build -> intermediates -> signing_config -> debug -> out -> signing-config.json
Delete signing-config.json file
And rebuild your application.
react-native run-android
First thing you need to delete node_mouldes and package.lock.json and do yarn install after that if you're using Windows OS you need to use PowerShell not git bash and write this command "react-native run-android"
Install npm again to latest
react-native init project_name
cd project_name
open android studio the same android folder inside your project_name
react_native run_android
will work now
for the last time your project was working fine and now you got this error suddenly and you have Node modules already installed then just trynpm install --save react-native
this work for me

Categories

Resources