I'm setting up my environment to code in react-native, and when I run
npx react-native run-android
the response is:
:ReactNative:Unexpected empty result of running '[node, C:\Users\fre_z\OneDrive\�?rea de Trabalho\Prog\OmegaApp\node_modules\#react-native-community\cli\build\bin.js, config]' command.
:ReactNative:Running '[node, C:\Users\fre_z\OneDrive\�?rea de Trabalho\Prog\OmegaApp\node_modules\#react-native-community\cli\build\bin.js, config]' command failed.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\fre_z\OneDrive\�rea de Trabalho\Prog\OmegaApp\node_modules\#react-native-community\cli-platform-android\native_modules.gradle' line: 213
* What went wrong:
A problem occurred evaluating script.
node:internal/modules/cjs/loader:936 throw err; ^Error: Cannot find module 'C:\Users\fre_z\OneDrive\�rea de Trabalho\Prog\OmegaApp\node_modules\#react-native-community\cli\build\bin.js' at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15) at Function.Module._load (node:internal/modules/cjs/loader:778:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:17:47 { code: 'MODULE_NOT_FOUND',
requireStack: []}
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan
to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 971ms
I know it's probably an error while I was setting up the environment. But, I don't know where, and I already redone it twice.
In your project, try to remove node modules and reinstall core-util-is:
rm -rf node_modules
npm install -g npm#latest
npm i core-util-is
I'm also guessing you cloned RN project created on other environment. So if above steps fail, you can try to create new RN project on your current setup - if it is 'compileable' you should be able to run cloned project also.
Another step worth to try - reinstal Node for your platform (https://nodejs.org/en/download/)
I don't know why, but i changed the folder where i cloned the project and it worked. I'm guessing it was because of the spaces and special characters in the path. When i cloned it in C: it worked.
Related
I trying to run my react-native anroid project. I use android 12 (S). And sdk verison 31.0.0. But i cant run my project.
My error :
PS C:\Users\omer2\OneDrive\Masaüstü\BosBirProje> npm run android
> BosBirProje#0.0.1 android
> react-native run-android
info JS server already running.
info Launching emulator...
info Successfully launched emulator.
info Installing the app...
:ReactNative:Unexpected empty result of running '[node, C:\Users\omer2\OneDrive\Masaüstü\BosBirProje\node_modules\#react-n
ative-community\cli\build\bin.js, config]' command.
:ReactNative:Running '[node, C:\Users\omer2\OneDrive\Masaüstü\BosBirProje\node_modules\#react-native-community\cli\build\b
in.js, config]' command failed.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\omer2\OneDrive\Masa�st�\BosBirProje\node_modules\#react-native-community\cli-platform-android\native_modu
les.gradle' line: 413
* What went wrong:
A problem occurred evaluating script.
> node:internal/modules/cjs/loader:998 throw err; ^Error: Cannot find module 'C:\Users\omer2\OneDrive\Masaüstü\BosBirP
roje\node_modules\#react-native-community\cli\build\bin.js' at Module._resolveFilename (node:internal/modules/cjs/loade
r:995:15) at Module._load (node:internal/modules/cjs/loader:841:27) at Function.executeUserEntryPoint [as runMain] (
node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:23:47 { code: 'MODULE_NOT_FOUND', require
Stack: []}Node.js v18.12.1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BU�LD FAILED in 6s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/do
cs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
:ReactNative:Unexpected empty result of running '[node, C:\Users\omer2\OneDrive\Masaüstü\BosBirProje\node_modules\#react-n
ative-community\cli\build\bin.js, config]' command.
:ReactNative:Running '[node, C:\Users\omer2\OneDrive\Masaüstü\BosBirProje\node_modules\#react-native-community\cli\build\b
in.js, config]' command failed.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\omer2\OneDrive\Masa�st�\BosBirProje\node_modules\#react-native-community\cli-platform-android\native_modu
les.gradle' line: 413
* What went wrong:
A problem occurred evaluating script.
> node:internal/modules/cjs/loader:998 throw err; ^Error: Cannot find module 'C:\Users\omer2\OneDrive\Masaüstü\BosBirP
roje\node_modules\#react-native-community\cli\build\bin.js' at Module._resolveFilename (node:internal/modules/cjs/loade
r:995:15) at Module._load (node:internal/modules/cjs/loader:841:27) at Function.executeUserEntryPoint [as runMain] (
node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:23:47 { code: 'MODULE_NOT_FOUND', require
Stack: []}Node.js v18.12.1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BU�LD FAILED in 6s
at makeError (C:\Users\omer2\OneDrive\Masaüstü\BosBirProje\node_modules\execa\index.js:174:9)
at C:\Users\omer2\OneDrive\Masaüstü\BosBirProje\node_modules\execa\index.js:278:16
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async runOnAllDevices (C:\Users\omer2\OneDrive\Masaüstü\BosBirProje\node_modules\react-native\node_modules\#react-n
ative-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
at async Command.handleAction (C:\Users\omer2\OneDrive\Masaüstü\BosBirProje\node_modules\#react-native-community\cli\b
uild\index.js:108:9)
info Run CLI with --verbose flag for more details.
I trying to react-native doctor and my react-native doctor output:
PS C:\Users\omer2\OneDrive\Masaüstü\BosBirProje> npx #react-native-community/cli doctor
Common
✓ Node.js
✓ npm
Android
✓ JDK
✓ Android Studio - Required for building and installing your app on Android
✖ Android SDK - Required for building and installing your app on Android
- Versions found: N/A
- Version supported: 31.0.0
✓ ANDROID_HOME
Errors: 1
Warnings: 0
Attempting to fix 1 issue...
Android
✔ Android SDK configured. You might need to restart your PC for all changes to take effect.
I reboot my pc as suggested and do npm run android. And my new output:
PS C:\Users\omer2\OneDrive\Masaüstü\BosBirProje> npm run android
> BosBirProje#0.0.1 android
> react-native run-android
info JS server already running.
info Installing the app...
:ReactNative:Unexpected empty result of running '[node, C:\Users\omer2\OneDrive\Masaüstü\BosBirProje\node_modules\#react-n
ative-community\cli\build\bin.js, config]' command.
:ReactNative:Running '[node, C:\Users\omer2\OneDrive\Masaüstü\BosBirProje\node_modules\#react-native-community\cli\build\b
in.js, config]' command failed.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\omer2\OneDrive\Masa�st�\BosBirProje\node_modules\#react-native-community\cli-platform-android\native_modu
les.gradle' line: 413
* What went wrong:
A problem occurred evaluating script.
> node:internal/modules/cjs/loader:998 throw err; ^Error: Cannot find module 'C:\Users\omer2\OneDrive\Masaüstü\BosBirP
roje\node_modules\#react-native-community\cli\build\bin.js' at Module._resolveFilename (node:internal/modules/cjs/loade
r:995:15) at Module._load (node:internal/modules/cjs/loader:841:27) at Function.executeUserEntryPoint [as runMain] (
node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:23:47 { code: 'MODULE_NOT_FOUND', require
Stack: []}Node.js v18.12.1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BU�LD FAILED in 6s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/do
cs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
:ReactNative:Unexpected empty result of running '[node, C:\Users\omer2\OneDrive\Masaüstü\BosBirProje\node_modules\#react-n
ative-community\cli\build\bin.js, config]' command.
:ReactNative:Running '[node, C:\Users\omer2\OneDrive\Masaüstü\BosBirProje\node_modules\#react-native-community\cli\build\b
in.js, config]' command failed.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\omer2\OneDrive\Masa�st�\BosBirProje\node_modules\#react-native-community\cli-platform-android\native_modu
les.gradle' line: 413
* What went wrong:
A problem occurred evaluating script.
> node:internal/modules/cjs/loader:998 throw err; ^Error: Cannot find module 'C:\Users\omer2\OneDrive\Masaüstü\BosBirP
roje\node_modules\#react-native-community\cli\build\bin.js' at Module._resolveFilename (node:internal/modules/cjs/loade
r:995:15) at Module._load (node:internal/modules/cjs/loader:841:27) at Function.executeUserEntryPoint [as runMain] (
node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:23:47 { code: 'MODULE_NOT_FOUND', require
Stack: []}Node.js v18.12.1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BU�LD FAILED in 6s
at makeError (C:\Users\omer2\OneDrive\Masaüstü\BosBirProje\node_modules\execa\index.js:174:9)
at C:\Users\omer2\OneDrive\Masaüstü\BosBirProje\node_modules\execa\index.js:278:16
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async runOnAllDevices (C:\Users\omer2\OneDrive\Masaüstü\BosBirProje\node_modules\react-native\node_modules\#react-n
ative-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
at async Command.handleAction (C:\Users\omer2\OneDrive\Masaüstü\BosBirProje\node_modules\#react-native-community\cli\b
uild\index.js:108:9)
info Run CLI with --verbose flag for more details.
1-) Finally I added the local.properties file to this location "C:\Users\omer2\OneDrive\Desktop\BosBirProject\android".
2-) I added the following commands in the gradle.properties file:
newArchEnabled=false
android.useAndroidX=true
android.enableJetifier=true
3-) I updated and reinstalled all npm packages
4-) I also tried to :
npm uninstall -g react-native-cli
npm install -g react-native-cli
npm install -g react-native
5-) I can't run the project even though I did all these, what would you recommend to me?
I am now using react native cli in my crud project,but after I initialized the project and ran npx react-native run-android inside project folder
it gave me these errors :
npx react-native run-android
info Starting JS server...
* daemon not running; starting now at tcp:5037
* daemon started successfully
info Launching emulator...
info Successfully launched emulator.
info Installing the app...
:ReactNative:Unexpected empty result of running '[node, C:\Users\invis\OneDrive\�?rea de Trabalho\reac\app\node_modules\#react-native-community\cli\build\bin.js, config]' command.
:ReactNative:Running '[node, C:\Users\invis\OneDrive\�?rea de Trabalho\reac\app\node_modules\#react-native-community\cli\build\bin.js, config]' command failed.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\invis\OneDrive\�rea de Trabalho\reac\app\node_modules\#react-native-community\cli-platform-android\native_modules.gradle' line: 413
* What went wrong:
A problem occurred evaluating script.
> node:internal/modules/cjs/loader:988 throw err; ^Error: Cannot find module 'C:\Users\invis\OneDrive\�rea de Trabalho\reac\app\node_modules\#react-native-community\cli\build\bin.js' at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15) at Function.Module._load (node:internal/modules/cjs/loader:833:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:22:47 { code: 'MODULE_NOT_FOUND', requireStack: []}
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 8s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
:ReactNative:Unexpected empty result of running '[node, C:\Users\invis\OneDrive\�?rea de Trabalho\reac\app\node_modules\#react-native-community\cli\build\bin.js, config]' command.
:ReactNative:Running '[node, C:\Users\invis\OneDrive\�?rea de Trabalho\reac\app\node_modules\#react-native-community\cli\build\bin.js, config]' command failed.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\invis\OneDrive\�rea de Trabalho\reac\app\node_modules\#react-native-community\cli-platform-android\native_modules.gradle' line: 413
* What went wrong:
A problem occurred evaluating script.
> node:internal/modules/cjs/loader:988 throw err; ^Error: Cannot find module 'C:\Users\invis\OneDrive\�rea de Trabalho\reac\app\node_modules\#react-native-community\cli\build\bin.js' at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15) at Function.Module._load (node:internal/modules/cjs/loader:833:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:22:47 { code: 'MODULE_NOT_FOUND', requireStack: []}
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 8s
at makeError (C:\Users\invis\OneDrive\Área de Trabalho\reac\app\node_modules\#react-native-community\cli-platform-android\node_modules\execa\index.js:174:9)
at C:\Users\invis\OneDrive\Área de Trabalho\reac\app\node_modules\#react-native-community\cli-platform-android\node_modules\execa\index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (C:\Users\invis\OneDrive\Área de Trabalho\reac\app\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
at async Command.handleAction (C:\Users\invis\OneDrive\Área de Trabalho\reac\app\node_modules\#react-native-community\cli\build\index.js:142:9)
info Run CLI with --verbose flag for more details.
At first I installed react native and react-native-community-cli globally and I saw it was a bad practice so I uninstalled it globally and installed again but now locally
I saw in a website the command
react-native doctor
And I saw at first some problems with SDK so I installed all packages necessary and it still AFTER ALL THIS gives me the same error again and again
I also tried deleting node modules ang installing again with
npm install
but unfortunately it did not work,if anyone has any ideas please send it ,I will be very grateful !!!
After A LOT of research,I found out that because my path system is written in portuguese ,my desktop is named "Área de Trabalho" ,it did not worked,I changed it to OneDrive directory which is 1 level upper in the directory tree and it DID worked fine!!! Hope I helped someone with the same problem!!! Have a good day !!!
I can run my rn project without error.I just create another for test something with
react-native init testapp
and then opened with vs code , run this command as usual
react-native run-android --no-jetifier
it runs the code in emulator.But now it gives error in new project like that.
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 971 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Installing the app...
:ReactNative:Unexpected empty result of running '[node, C:\Users\sampleuser\Desktop\samplee\testapp\node_modules\react-native\node_modules\#react-native-community\cli\build\bin.js, config]' command.
:ReactNative:Running '[node, C:\Users\sampleuser\Desktop\samplee\testapp\node_modules\react-native\node_modules\#react-native-community\cli\build\bin.js, config]' command failed.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\sampleuser\Desktop\samplee\testapp\node_modules\#react-native-community\cli-platform-android\native_modules.gradle' line: 195
* What went wrong:
A problem occurred evaluating script.
> internal/modules/cjs/loader.js:1033 throw err; ^Error: Cannot find module 'C:\Users\sampleuser\Desktop\samplee\testapp\node_modules\react-native\node_modules\#react-native-community\cli\build\bin.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1030:15) at Function.Module._load (internal/modules/cjs/loader.js:899:27) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) at internal/main/run_main_module.js:17:47 { code: 'MODULE_NOT_FOUND', requireStack: []}
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BU�LD FAILED in 1s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
also i tryed
npx react-native run-android
Also tryed
uninstall and reinstall nodemodules
Cold start Emulator
Update android sdk
Still gives same error
Also tryed to downgrade version
"dependencies": {
"react": "16.8.0",
"react-native": "0.60.0",
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\sampleuser\Desktop\samplee\testapp\android\app\build.gradle' line: 1
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.application']
> Your project path contains non-ASCII characters. This will most likely cause the build to fail on Windows. Please move your project to a different directory. See http://b.android.com/95744 for details. This warning can be disabled by adding the line 'android.overridePathCheck=true' to gradle.properties file in the project directory.
info JS server already running.
info Installing the app...
:ReactNative:Unexpected empty result of running '[node, \node_modules\react-native\node_modules\#react-native-community\cli\build\bin.js, config]' command.
:ReactNative:Running '[node, \node_modules\react-native\node_modules\#react-native-community\cli\build\bin.js, config]' command failed.
react-native --version
react-native-cli: 2.0.1
react-native: 0.63.2
You didn't enter your project file with "cd" command.You must run your command in your project file.That's why it gives this error.The solution is gonna be in these following steps.
When you initiliaze your project with command "npx react-native init testapp", you need to start metro bundler.(You can find the details about Metro) Before you start metro bundler,You should write down "cd testapp/" command in VS terminal.This will get in your project file.Than,write command which is gonna start metro "npx react-native start".
Secondly,let metro run in its own terminal.Open a new terminal inside your react native project folder.Get into your file again in this terminal too with "cd testapp/".
3.Finally,run your emulator from Android studio.And write "npx react-native run-android" command.(You can go look for how AVD starts with Android Stuido in this link)
Additionally,(VS code screenshot)
I want to make apk file of my application code, but whenever I am running gradlew assembleRelease it gives the following error, I just want to create the build with anything, as I have to deliver my project on Monday. Any help will be appreciated
C:\Users\dines\Documents\ANUJ\managementportal\android>gradlew assembleRelease
:ReactNative:Unexpected empty result of running '[node, undefined, config]' command.
:ReactNative:Running '[node, undefined, config]' command failed.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\dines\Documents\ANUJ\managementportal\node_modules\#react-native-community\cli-platform-android\native_modules.gradle' line: 170
* What went wrong:
A problem occurred evaluating script.
> internal/modules/cjs/loader.js:584 throw err; ^Error: Cannot find module 'C:\Users\dines\Documents\ANUJ\managementportal\android\undefined' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15) at Function.Module._load (internal/modules/cjs/loader.js:508:25) at Function.Module.runMain (internal/modules/cjs/loader.js:754:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
C:\Users\dines\Documents\ANUJ\managementportal\android>
Follow This Step:
1) C:\Users\dines\Documents\ANUJ\managementportal> react-native run-android
2) C:\Users\dines\Documents\ANUJ\managementportal> cd android
3) C:\Users\dines\Documents\ANUJ\managementportal\android> ./gradlew assembleRelease
All Process is done after getting release app
Project folder > android > app > build > outputs > apk > release
I am new to react-native and trying to build an android app using react native in Android Studio for Windows. After I install react-navigation, follow all the steps in the react-navigation documentation, I run react-native run-android and I get this error in the command line:
PS C:\Users\comp\Desktop\work\reactnative\dansapp> react-native run-android
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
FAILURE: Build failed with an exception.
* Where:
Settings file 'C:\Users\comp\Desktop\work\reactnative\dansapp\android\settings.gradle' line: 3
* What went wrong:
Could not compile settings file 'C:\Users\comp\Desktop\work\reactnative\dansapp\android\settings.gradle'.
> startup failed:
settings file 'C:\Users\comp\Desktop\work\reactnative\dansapp\android\settings.gradle': 3: unexpected char:
'\' # line 3, column 133.
s\react-native-gesture-handler\android')
^
1 error
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
Command failed: gradlew.bat installDebug
Error: Command failed: gradlew.bat installDebug
at checkExecSyncError (child_process.js:602:13)
at Object.execFileSync (child_process.js:622:13)
at runOnAllDevices (C:\Users\comp\Desktop\work\reactnative\dansapp\node_modules\react-native\local-cli\runAndroid\runAndroid.js:299:19)
at buildAndRun (C:\Users\comp\Desktop\work\reactnative\dansapp\node_modules\react-native\local-cli\runAndroid\runAndroid.js:135:12)
at isPackagerRunning.then.result (C:\Users\comp\Desktop\work\reactnative\dansapp\node_modules\react-native\local-cli\runAndroid\runAndroid.js:65:12)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)
PS C:\Users\comp\Desktop\work\reactnative\dansapp>
Does anyone know what this error is and how to resolve it? It seems to occur after I install react-navigation following these steps: https://reactnavigation.org/docs/en/getting-started.html
I have follwed the steps, including changing the mainActivity.java file. I also do not know what gradle is.
Any help would be greatly appreciated!
Known issue (see: bug with react-native link in android and windows), which will hopefully be fixed soon.
Jump into your settings.gradle file in /dansapp/android/ and replace...
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '..\node_modules\react-native-gesture-handler\android')
...with...
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')