I'm trying to run a new React native project on an Android emulator and i get this error
FAILURE: Build failed with an exception.
Where:
Script '...\AwesomeProject\node_modules#react-native-community\cli-platform-android\native_modules.gradle' line: 213
What went wrong:
A problem occurred evaluating script.
internal/modules/cjs/loader.js:905 throw err; ^Error: Cannot find module '...\AwesomeProject\node_modules\react-native\node_modules#react-native-community\cli\build\bin.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15) at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) at internal/main/run_main_module.js:17:47 { code: 'MODULE_NOT_FOUND', requireStack: []}
please someone help, i trying to fix that for a long time.
Related
for the past couple of days now, I've been trying to install react native using npx react-native init AppName, and since then I've been getting this error. I've searched the net and couldn't get a better answer to this problem, how do i go about solving it?
node:
internal/modules/cjs/loader:959
throw err;
^
Error: Cannot find module 'graceful-fs'
Require stack:
- C:\Users\HP\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\tools\gracefulifyFs.js
- C:\Users\HP\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\bin.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
at Function.Module._load (node:internal/modules/cjs/loader:804:27)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18)
at _gracefulFs (C:\Users\HP\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\tools\gracefulifyFs.js:19:39)
at Object.<anonymous> (C:\Users\HP\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\tools\gracefulifyFs.js:30:1)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\HP\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\build\\tools\\gracefulifyFs.js',
'C:\\Users\\HP\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\build\\bin.js'
]
}
I had the same problem.
sudo npm install
solved it for me.
When I run yarn start this error is showing with error command failed with exit code. How can I solve this?
yarn run v1.22.18
$ node -r #babel/register ./.erb/scripts/check-port-in-use.js && yarn start:renderer
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module '#babel/register'
Require stack:
- internal/preload
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at Module._preloadModules (node:internal/modules/cjs/loader:1282:12)
at loadPreloadModules (node:internal/bootstrap/pre_execution:539:5)
at prepareMainThreadExecution (node:internal/bootstrap/pre_execution:85:3)
at node:internal/main/run_main_module:7:1 {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'internal/preload' ]
internal/modules/cjs/loader.js:1088 throw err; ^
Error: Cannot find module
'C:\Users\PCNAME\AppData\Roaming\npm\node_modules\expo-c
li\bin\expo.js' ←[90m at Function.Module._resolveFilename
(internal/modules/cjs/loader.js:108 5:15)←[39m ←[90m at
Function.Module._load (internal/modules/cjs/loader.js:928:27)←[39m
←[90m at Function.executeUserEntryPoint [as runMain]
(internal/modules/run_ma in.js:60:12)←[39m ←[90m at
internal/main/run_main_module.js:17:47←[39m { code:
←[32m'MODULE_NOT_FOUND'←[39m, requireStack: [] }
Try restarting your server and simulator, or write npm install
I am facing this error after installing react-native-code-push.
Task :app:generateBundledResourcesHashRelease FAILED
internal/fs/utils.js:230
throw err;
^
Error: ENOENT: no such file or directory, scandir '/home/ayush/Desktop/awsproject/android/app/build/generated/res/react/release'
at Object.readdirSync (fs.js:872:3)
at getFilesInFolder (/home/ayush/Desktop/awsproject/node_modules/react-native-code-push/scripts/getFilesInFolder.js:7:26)
at Object.<anonymous> (/home/ayush/Desktop/awsproject/node_modules/react-native-code-push/scripts/generateBundledResourcesHash.js:38:1)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47 {
errno: -2,
syscall: 'scandir',
code: 'ENOENT',
path: '/home/ayush/Desktop/awsproject/android/app/build/generated/res/react/release'
}
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:generateBundledResourcesHashRelease'.
> Process 'command 'node'' finished with non-zero exit value 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.1.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 36s
52 actionable tasks: 52 executed
go to node_modules/react-native-code-push/android/codepush.gradle
It appears that the only change needed to make this work is to add 2 mkdirs() calls to the codepush gradle task, like so:
//...
if (variant.hasProperty("bundleJsAndAssets")) {z
def reactBundleTask = variant.bundleJsAndAssets
jsBundleDir = reactBundleTask.generatedAssetsFolders[0].absolutePath
resourcesDir = reactBundleTask.generatedResFolders[0].absolutePath
//add these 2 lines
new File(jsBundleDir).mkdirs()
new File(resourcesDir).mkdirs()
jsBundleFile = file("$jsBundleDir/$bundleAssetName")
//...
Using Node.js v12.13.0 internal/modules/cjs/loader.js:797
throw err;
^
Error: Cannot find module '/Users/ABC/Projects/ReactNative/Project ABCD'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
at Function.Module._load (internal/modules/cjs/loader.js:687:27)
at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)
at internal/main/run_main_module.js:17:11 { code: 'MODULE_NOT_FOUND', requireStack: [] }
Command PhaseScriptExecution failed with a nonzero exit code
It seems like you are trying to reference a module that lives somewhere else. Can we see project code and file structure?
I resolved this issue by just removing a space from project folder name.
'Project ABCD' -> 'Project_ABCD'