node:internal/modules/cjs/loader:936 npx react-native run-android

Viewed 2666

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.

2 Answers

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