cli icon indicating copy to clipboard operation
cli copied to clipboard

even when rn doctor does not detect any error, npx rn run android does not work

Open rmlinx opened this issue 2 years ago • 15 comments

am new here, so already sorry if I committed any mistake in this prompt. So I am willing to create an app, I followed all the instructions on the starter page but, when I try to run "npx react-natin run-android" i get as a feed back this `S C:\Users\Ricardo\OneDrive - ufpr.br\Documentos\Área de Trabalho\SmartMobility 2.0\AwesomeProject> npx react-native run-android info JS server already running.

info 💡 Tip: Make sure that you have set up your development environment correctly, by running react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor

:ReactNative:Unexpected empty result of running '[node, C:\Users\Ricardo\OneDrive - ufpr.br\Documentos\�?rea de Trabalho\SmartMobility 2.0\AwesomeProject\node_modules@react-native-community\cli\build\bin.js, config]' command. :ReactNative:Running '[node, C:\Users\Ricardo\OneDrive - ufpr.br\Documentos\�?rea de Trabalho\SmartMobility 2.0\AwesomeProject\node_modules@react-native-community\cli\build\bin.js, config]' command failed.

FAILURE: Build failed with an exception.

  • Where: Script 'C:\Users\Ricardo\OneDrive - ufpr.br\Documentos\�rea de Trabalho\SmartMobility 2.0\AwesomeProject\node_modules@react-native-community\cli-platform-android\native_modules.gradle' line: 389

  • What went wrong: A problem occurred evaluating script.

node:internal/modules/cjs/loader:1051 throw err; ^Error: Cannot find module 'C:\Users\Ricardo\OneDrive - ufpr.br\Documentos\�rea de Trabalho\SmartMobility 2.0\AwesomeProject\node_modules@react-native-community\cli\build\bin.js' at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15) at Module._load (node:internal/modules/cjs/loader:901:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12) at node:internal/main/run_main_module:23:47 { code: 'MODULE_NOT_FOUND', requireStack: []}Node.js v20.9.0

  • 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`

What can i do? the doctor function says that everything is ok

rmlinx avatar Nov 06 '23 00:11 rmlinx

Hey @rmlinx, could you please run npx react-native config inside your project and say if it works correctly (it should print an object containing informations about your project).

szymonrybczak avatar Nov 06 '23 06:11 szymonrybczak

hi, sorry for the delay into the response, probably because of time zones i have missed the notification, btw here is what you asked PS C:\Users\Ricardo\OneDrive - ufpr.br\Documentos\Área de Trabalho\SmartMobility 2.0\SmarMobilityPRO> npx react-native config { "root": "C:\\Users\\Ricardo\\OneDrive - ufpr.br\\Documentos\\Área de Trabalho\\SmartMobility 2.0\\SmarMobilityPRO", "reactNativePath": "C:\\Users\\Ricardo\\OneDrive - ufpr.br\\Documentos\\Área de Trabalho\\SmartMobility 2.0\\SmarMobilityPRO\\node_modules\\react-native", "reactNativeVersion": "0.72", "dependencies": {}, "commands": [ { "name": "log-ios", "description": "starts iOS device syslog tail", "options": [ { "name": "--interactive", "description": "Explicitly select simulator to tail logs from. By default it will tail logs from the first booted and available simulator." } ] }, { "name": "run-ios", "description": "builds your app and starts it on iOS simulator", "examples": [ { "desc": "Run on a different simulator, e.g. iPhone SE (2nd generation)", "cmd": "react-native run-ios --simulator \"iPhone SE (2nd generation)\"" }, { "desc": "Run on a connected device, e.g. Max's iPhone", "cmd": "react-native run-ios --device \"Max's iPhone\"" }, { "desc": "Run on the AppleTV simulator", "cmd": "react-native run-ios --simulator \"Apple TV\" --scheme \"helloworld-tvOS\"" } ], "options": [ { "name": "--simulator <string>", "description": "Explicitly set simulator to use. Optionally include iOS version between parenthesis at the end to match an exact version: \"iPhone 6 (10.0)\"" }, { "name": "--mode <string>", "description": "Explicitly set the scheme configuration to use. This option is case sensitive." }, { "name": "--configuration <string>", "description": "[Deprecated] Explicitly set the scheme configuration to use" }, { "name": "--scheme <string>", "description": "Explicitly set Xcode scheme to use" }, { "name": "--device [string]", "description": "Explicitly set device to use by name. The value is not required if you have a single device connected." }, { "name": "--destination <string>", "description": "Explicitly extend distination e.g. \"arch=x86_64\"" }, { "name": "--udid <string>", "description": "Explicitly set device to use by udid" }, { "name": "--verbose", "description": "Do not use xcbeautify or xcpretty even if installed" }, { "name": "--port <number>", "default": 8081 }, { "name": "--terminal <string>", "description": "Launches the Metro Bundler in a new window using the specified terminal path." }, { "name": "--xcconfig [string]", "description": "Explicitly set xcconfig to use" }, { "name": "--buildFolder <string>", "description": "Location for iOS build artifacts. Corresponds to Xcode's \"-derivedDataPath\"." }, { "name": "--extra-params <string>", "description": "Custom params that will be passed to xcodebuild command." }, { "name": "--no-packager", "description": "Do not launch packager while building" }, { "name": "--binary-path <string>", "description": "Path relative to project root where pre-built .app binary lives." }, { "name": "--list-devices", "description": "List all available iOS devices and simulators and let you choose one to run the app. " }, { "name": "--interactive", "description": "Explicitly select which scheme and configuration to use before running a build and select device to run the application." } ] }, { "name": "build-ios", "description": "builds your app on iOS simulator", "examples": [ { "desc": "Build the app for the IOS simulator", "cmd": "react-native build-ios" }, { "desc": "Build the app for all IOS devices", "cmd": "react-native build-ios --mode \"Release\"" }, { "desc": "Build the app for a specific IOS device", "cmd": "react-native build-ios --simulator \"IPhone 11\"" } ], "options": [ { "name": "--simulator <string>", "description": "Explicitly set simulator to use. Optionally include iOS version between parenthesis at the end to match an exact version: \"iPhone 6 (10.0)\"" }, { "name": "--mode <string>", "description": "Explicitly set the scheme configuration to use. This option is case sensitive." }, { "name": "--configuration <string>", "description": "[Deprecated] Explicitly set the scheme configuration to use" }, { "name": "--scheme <string>", "description": "Explicitly set Xcode scheme to use" }, { "name": "--device [string]", "description": "Explicitly set device to use by name. The value is not required if you have a single device connected." }, { "name": "--destination <string>", "description": "Explicitly extend distination e.g. \"arch=x86_64\"" }, { "name": "--udid <string>", "description": "Explicitly set device to use by udid" }, { "name": "--verbose", "description": "Do not use xcbeautify or xcpretty even if installed" }, { "name": "--port <number>", "default": 8081 }, { "name": "--terminal <string>", "description": "Launches the Metro Bundler in a new window using the specified terminal path." }, { "name": "--xcconfig [string]", "description": "Explicitly set xcconfig to use" }, { "name": "--buildFolder <string>", "description": "Location for iOS build artifacts. Corresponds to Xcode's \"-derivedDataPath\"." }, { "name": "--extra-params <string>", "description": "Custom params that will be passed to xcodebuild command." }, { "name": "--interactive", "description": "Explicitly select which scheme and configuration to use before running a build" } ] }, { "name": "log-android", "description": "starts logkitty" }, { "name": "run-android", "description": "builds your app and starts it on a connected Android emulator or device", "options": [ { "name": "--mode <string>", "description": "Specify your app's build variant" }, { "name": "--variant <string>", "description": "Specify your app's build variant. Deprecated! Use 'mode' instead" }, { "name": "--no-packager", "description": "Do not launch packager while building" }, { "name": "--port <number>", "default": 8081 }, { "name": "--terminal <string>", "description": "Launches the Metro Bundler in a new window using the specified terminal path." }, { "name": "--tasks <list>", "description": "Run custom Gradle tasks. By default it's \"assembleDebug\". Will override passed mode and variant arguments." }, { "name": "--active-arch-only", "description": "Build native libraries only for the current device architecture for debug builds.", "default": false }, { "name": "--extra-params <string>", "description": "Custom params passed to gradle build command" }, { "name": "--interactive", "description": "Explicitly select build type and flavour to use before running a build" }, { "name": "--appId <string>", "description": "Specify an applicationId to launch after build. If not specified, package from AndroidManifest.xml will be used.", "default": "" }, { "name": "--appIdSuffix <string>", "description": "Specify an applicationIdSuffix to launch after build.", "default": "" }, { "name": "--main-activity <string>", "description": "Name of the activity to start", "default": "MainActivity" }, { "name": "--deviceId <string>", "description": "builds your app and starts it on a specific device/simulator with the given device id (listed by running \"adb devices\" on the command line)." }, { "name": "--list-devices", "description": "Lists all available Android devices and simulators and let you choose one to run the app", "default": false }, { "name": "--binary-path <string>", "description": "Path relative to project root where pre-built .apk binary lives." }, { "name": "--user <number>", "description": "Id of the User Profile you want to install the app on." } ] }, { "name": "build-android", "description": "builds your app", "options": [ { "name": "--mode <string>", "description": "Specify your app's build variant" }, { "name": "--variant <string>", "description": "Specify your app's build variant. Deprecated! Use 'mode' instead" }, { "name": "--no-packager", "description": "Do not launch packager while building" }, { "name": "--port <number>", "default": 8081 }, { "name": "--terminal <string>", "description": "Launches the Metro Bundler in a new window using the specified terminal path." }, { "name": "--tasks <list>", "description": "Run custom Gradle tasks. By default it's \"assembleDebug\". Will override passed mode and variant arguments." }, { "name": "--active-arch-only", "description": "Build native libraries only for the current device architecture for debug builds.", "default": false }, { "name": "--extra-params <string>", "description": "Custom params passed to gradle build command" }, { "name": "--interactive", "description": "Explicitly select build type and flavour to use before running a build" } ] } ], "healthChecks": [], "platforms": { "ios": {}, "android": {} }, "project": { "ios": { "sourceDir": "C:\\Users\\Ricardo\\OneDrive - ufpr.br\\Documentos\\Área de Trabalho\\SmartMobility 2.0\\SmarMobilityPRO\\ios", "xcodeProject": { "name": "SmarMobilityPRO.xcodeproj", "isWorkspace": false } }, "android": { "sourceDir": "C:\\Users\\Ricardo\\OneDrive - ufpr.br\\Documentos\\Área de Trabalho\\SmartMobility 2.0\\SmarMobilityPRO\\android", "appName": "app", "packageName": "com.smarmobilitypro" } } }

to be realistc, i didnt understood any of this lmao, in advance, thank you very much for the help

rmlinx avatar Nov 07 '23 01:11 rmlinx

sorry unintentionally closed the doubt, so ... the formatting went missing in the last comment, here is it, with the layout { "root": "C:\Users\Ricardo\OneDrive - ufpr.br\Documentos\Área de Trabalho\SmartMobility 2.0\SmarMobilityPRO", "reactNativePath": "C:\Users\Ricardo\OneDrive - ufpr.br\Documentos\Área de Trabalho\SmartMobility 2.0\SmarMobilityPRO\node_modules\react-native", "reactNativeVersion": "0.72", "dependencies": {}, "commands": [ { "name": "log-ios", "description": "starts iOS device syslog tail", "options": [ { "name": "--interactive", "description": "Explicitly select simulator to tail logs from. By default it will tail logs from the first booted and available simulator." } ] }, { "name": "run-ios", "description": "builds your app and starts it on iOS simulator", "examples": [ { "desc": "Run on a different simulator, e.g. iPhone SE (2nd generation)", "cmd": "react-native run-ios --simulator "iPhone SE (2nd generation)"" }, { "desc": "Run on a connected device, e.g. Max's iPhone", "cmd": "react-native run-ios --device "Max's iPhone"" }, { "desc": "Run on the AppleTV simulator", "cmd": "react-native run-ios --simulator "Apple TV" --scheme "helloworld-tvOS"" } ], "options": [ { "name": "--simulator ", "description": "Explicitly set simulator to use. Optionally include iOS version between parenthesis at the end to match an exact version: "iPhone 6 (10.0)"" }, { "name": "--mode ", "description": "Explicitly set the scheme configuration to use. This option is case sensitive." }, { "name": "--configuration ", "description": "[Deprecated] Explicitly set the scheme configuration to use" }, { "name": "--scheme ", "description": "Explicitly set Xcode scheme to use" }, { "name": "--device [string]", "description": "Explicitly set device to use by name. The value is not required if you have a single device connected." }, { "name": "--destination ", "description": "Explicitly extend distination e.g. "arch=x86_64"" }, { "name": "--udid ", "description": "Explicitly set device to use by udid" }, { "name": "--verbose", "description": "Do not use xcbeautify or xcpretty even if installed" }, { "name": "--port ", "default": 8081 }, { "name": "--terminal ", "description": "Launches the Metro Bundler in a new window using the specified terminal path." }, { "name": "--xcconfig [string]", "description": "Explicitly set xcconfig to use" }, { "name": "--buildFolder ", "description": "Location for iOS build artifacts. Corresponds to Xcode's "-derivedDataPath"." }, { "name": "--extra-params ", "description": "Custom params that will be passed to xcodebuild command." }, { "name": "--no-packager", "description": "Do not launch packager while building" }, { "name": "--binary-path ", "description": "Path relative to project root where pre-built .app binary lives." }, { "name": "--list-devices", "description": "List all available iOS devices and simulators and let you choose one to run the app. " }, { "name": "--interactive", "description": "Explicitly select which scheme and configuration to use before running a build and select device to run the application." } ] }, { "name": "build-ios", "description": "builds your app on iOS simulator", "examples": [ { "desc": "Build the app for the IOS simulator", "cmd": "react-native build-ios" }, { "desc": "Build the app for all IOS devices", "cmd": "react-native build-ios --mode "Release"" }, { "desc": "Build the app for a specific IOS device", "cmd": "react-native build-ios --simulator "IPhone 11"" } ], "options": [ { "name": "--simulator ", "description": "Explicitly set simulator to use. Optionally include iOS version between parenthesis at the end to match an exact version: "iPhone 6 (10.0)"" }, { "name": "--mode ", "description": "Explicitly set the scheme configuration to use. This option is case sensitive." }, { "name": "--configuration ", "description": "[Deprecated] Explicitly set the scheme configuration to use" }, { "name": "--scheme ", "description": "Explicitly set Xcode scheme to use" }, { "name": "--device [string]", "description": "Explicitly set device to use by name. The value is not required if you have a single device connected." }, { "name": "--destination ", "description": "Explicitly extend distination e.g. "arch=x86_64"" }, { "name": "--udid ", "description": "Explicitly set device to use by udid" }, { "name": "--verbose", "description": "Do not use xcbeautify or xcpretty even if installed" }, { "name": "--port ", "default": 8081 }, { "name": "--terminal ", "description": "Launches the Metro Bundler in a new window using the specified terminal path." }, { "name": "--xcconfig [string]", "description": "Explicitly set xcconfig to use" }, { "name": "--buildFolder ", "description": "Location for iOS build artifacts. Corresponds to Xcode's "-derivedDataPath"." }, { "name": "--extra-params ", "description": "Custom params that will be passed to xcodebuild command." }, { "name": "--interactive", "description": "Explicitly select which scheme and configuration to use before running a build" } ] }, { "name": "log-android", "description": "starts logkitty" }, { "name": "run-android", "description": "builds your app and starts it on a connected Android emulator or device", "options": [ { "name": "--mode ", "description": "Specify your app's build variant" }, { "name": "--variant ", "description": "Specify your app's build variant. Deprecated! Use 'mode' instead" }, { "name": "--no-packager", "description": "Do not launch packager while building" }, { "name": "--port ", "default": 8081 }, { "name": "--terminal ", "description": "Launches the Metro Bundler in a new window using the specified terminal path." }, { "name": "--tasks ", "description": "Run custom Gradle tasks. By default it's "assembleDebug". Will override passed mode and variant arguments." }, { "name": "--active-arch-only", "description": "Build native libraries only for the current device architecture for debug builds.", "default": false }, { "name": "--extra-params ", "description": "Custom params passed to gradle build command" }, { "name": "--interactive", "description": "Explicitly select build type and flavour to use before running a build" }, { "name": "--appId ", "description": "Specify an applicationId to launch after build. If not specified, package from AndroidManifest.xml will be used.", "default": "" }, { "name": "--appIdSuffix ", "description": "Specify an applicationIdSuffix to launch after build.", "default": "" }, { "name": "--main-activity ", "description": "Name of the activity to start", "default": "MainActivity" }, { "name": "--deviceId ", "description": "builds your app and starts it on a specific device/simulator with the given device id (listed by running "adb devices" on the command line)." }, { "name": "--list-devices", "description": "Lists all available Android devices and simulators and let you choose one to run the app", "default": false }, { "name": "--binary-path ", "description": "Path relative to project root where pre-built .apk binary lives." }, { "name": "--user ", "description": "Id of the User Profile you want to install the app on." } ] }, { "name": "build-android", "description": "builds your app", "options": [ { "name": "--mode ", "description": "Specify your app's build variant" }, { "name": "--variant ", "description": "Specify your app's build variant. Deprecated! Use 'mode' instead" }, { "name": "--no-packager", "description": "Do not launch packager while building" }, { "name": "--port ", "default": 8081 }, { "name": "--terminal ", "description": "Launches the Metro Bundler in a new window using the specified terminal path." }, { "name": "--tasks ", "description": "Run custom Gradle tasks. By default it's "assembleDebug". Will override passed mode and variant arguments." }, { "name": "--active-arch-only", "description": "Build native libraries only for the current device architecture for debug builds.", "default": false }, { "name": "--extra-params ", "description": "Custom params passed to gradle build command" }, { "name": "--interactive", "description": "Explicitly select build type and flavour to use before running a build" } ] } ], "healthChecks": [], "platforms": { "ios": {}, "android": {} }, "project": { "ios": { "sourceDir": "C:\Users\Ricardo\OneDrive - ufpr.br\Documentos\Área de Trabalho\SmartMobility 2.0\SmarMobilityPRO\ios", "xcodeProject": { "name": "SmarMobilityPRO.xcodeproj", "isWorkspace": false } }, "android": { "sourceDir": "C:\Users\Ricardo\OneDrive - ufpr.br\Documentos\Área de Trabalho\SmartMobility 2.0\SmarMobilityPRO\android", "appName": "app", "packageName": "com.smarmobilitypro" } } }

rmlinx avatar Nov 07 '23 01:11 rmlinx

Could you please run app from Android Studio?

szymonrybczak avatar Nov 07 '23 15:11 szymonrybczak

Could you please run app from Android Studio?< What should i do after opening the folder?

rmlinx avatar Nov 08 '23 01:11 rmlinx

@rmlinx just click Run button in right top corner.

szymonrybczak avatar Nov 08 '23 14:11 szymonrybczak

@rmlinx just click Run button in right top corner.

The button is greyed out😔

rmlinx avatar Nov 08 '23 15:11 rmlinx

@rmlinx Hi, I am getting the same error. Did you fix the error?

Ramazanzade avatar Dec 25 '23 12:12 Ramazanzade

@rmlinx Hi, I am getting the same error. Did you fix the error?

Nah, i couldnt solve it, just gave up, and changed the computer i was using, problaly something related to a config, but i dont know what or why

rmlinx avatar Dec 25 '23 16:12 rmlinx

Are you serious ? Thanks for your reply

Ramazanzade avatar Dec 25 '23 16:12 Ramazanzade

Are you serious ? Thanks for your reply

Ye☹️

rmlinx avatar Dec 25 '23 17:12 rmlinx

@Ramazanzade one reason the run button will be greyed out is if the project state isn't in sync with Gradle. You might see this banner at the top of the editor window when looking at build.gradle and other files:

image

If you. see that, try 'Sync now' and see if it completes. If it's not there, you can choose "Sync Project with Gradle Files" from the toolbar (button has an elephant and an arrow on it). It's also in the File menu.

See if that completes successfully and enables the run button.

liamjones avatar Jan 02 '24 13:01 liamjones

There hasn't been any activity on this issue in the past 3 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.

github-actions[bot] avatar Apr 02 '24 03:04 github-actions[bot]

@rmlinx A similar problem has happened to me before, Let's look into it.

If i understood it correctly the key parts are... Error Message Unexpected empty result of running command ( Could be project setup, environment configuration) Cant find the module specifically bin.js. ( Check all three... path issues, or missing modules or incorrect installations. Path with special characters ( since we speak the same language this happens to me aswell, when i write code in my natural language) you defined the path as Área de Trabalho. this could lead to issues in some systems with tooling on various operating systems. Meaning if it cant handle such characters.

Workaround 1 : For the path error with special characters try moving Área de Trabalho, into a seperate path without special characters and spaces like C:\Projects\AwesomeProject. ( the special character being the way we use Á

Workaround 2: There is a possibility that the Node Modules didn't install correctly, or that there are missing modules. The fix could be to delete node_modules folder. Navigate to your project directory in the command line run rm-rf node_modules if you are not using linux/macOS. use rmdir /s /q node_modules if on windows. then delete the package.lock.json or yarn.lock If they are present!. You can always reinstall dependencies by running npm install or yarn install.

Workaround 3: Try Clearing Cache, this can also cause issues sometimes. run npm start -- --reset cache or yarn start --reset cache ( to reset the metro bundler the thing that combines your javascript code in react native). i presume you are using android you can try cleaning the Gradle build by navigating into your folder android folder. (cd android) and run the command ./gradlew clean.

Workaround 4: Ensure the environment setup. you mentioned that the doctor indicated it was properly setup. Verify this by following the react-native environment setup guide.

Lastly run with debugging options. what we can see in the error message is that it suggest to run --stacktrace, --info, or --debug. for more detailed outputs. navigate to the projects android directory (cd android). run `./gradlew assembleDebug --stacktrace. this gives a more detailed error message which can help diagnose the problem if the issue persists.

Visual Example of the Directory Change C:\Users\Ricardo\OneDrive - ufpr.br\Documentos\Área de Trabalho\SmartMobility 2.0\AwesomeProject : turned into

C:\Projects\AwesomeProject.

Espero que ajude.

Devjosef avatar Apr 05 '24 06:04 Devjosef

just run these command

npx react-native run-android

and then try this

npm start --reset-cache npm start --reset-cache

mmejaz avatar May 11 '24 07:05 mmejaz

When solving this kind of problems please make sure to reset cache e.g. with npx react-native clean command. If there are any other issue presented please report new issues.

szymonrybczak avatar Jun 24 '24 19:06 szymonrybczak