Android React - Getting "Requiring unknown module react" - android

I keep getting this error when running the app on mobile android device, can anyone help.
The actual error:
Error: Requiring unknown module "react". If you are sure the module is there, try restarting the package or running "npm install". (index.android.bundle:93)

This is a pretty common error when developing React Native apps
Standing in the project root fgrep -rlo "React" . | grep -v "node_modules" will give you all places where "React" is being called
If this doesn't help you find your issue, there are lots of things you can try but you will have to provide more code
Hope this helps

Try deleting the node_modules folder and run npm install in command line at project root directory.
If it still fails, try to run npm install react --save

Related

problem with running flutter app in vscode

when I run my app I get this error :
Error: ADB exited with exit code 1
Performing Streamed Install
adb: failed to install F:\flutter-project\1\third_app\third_app\build\app\outputs\apk\app.apk: Failure [INSTALL_FAILED_INVALID_APK: Package couldn't be installed in /data/app/com.example.third_app-1: Package /data/app/com.example.third_app-1/base.apk code is missing]
Error launching application on Android SDK built for x86.
update:
I run flutter clear in the terminal and after restarting my computer and executing again, the problem solved
One of the SO post mentioned in the comment:
For Flutter projects, with VS Code editor, go to the project source
folder and delete the "build" folder and start debugging.
This could also be attained by running flutter clean from the terminal. This command helps you delete build cache which is in the /build folder. You can always uses this command when there are any bugs in the build process.

React native build failed: The development server returned response error code 500

enter image description here
Browser's console Error:
Bundling index.android.js [development, non-minified, hmr disabled] 99.3% (1074/1078), failed.
Error: Uncaught error in the transformer worker: /home/manish/donut/node_modules/metro-bundler/src/transformer.js
at _transform.then.catch.error (/home/manish/donut/node_modules/metro-bundler/src/JSTransformer/index.js:172:31)
at process._tickCallback (internal/process/next_tick.js:109:7)
Make sure you have run the npm server. From your project root folder
Open terminal cd project root and run the following command
npm start
And if you are using command to compile and run the app on device or simulator, then make sure you have run the
react-native run-android or run-ios
command from different terminal, to make sure you have not closed terminal which you run npm start.
And see whether server started successfully
This can happen if import is not proper. Example if I try to import something like this below
import renderIf from './renderIf';
and there is renderIf file present in my project.
So all these types of issues will get printed in npm server logs. See the logs and fix it accordingly.

react native app cannot fetch bundle

Although npm start or react-native start is running
app gives this error:
When I searched I tried npm install it gives this error:
How to fix this?
It seems like missing a dependency of the react native project.
The prompt show very clear,Unable to connect your device to the packager sever.
If your device and your computer under the same wi-fi,You can according to the last attempt to modify the connection attributes of your device.
install the dependency packages
npm install --force react#15.3.1
instead of
npm install react#15.3.1

react native run hello world

I am using this tutorial
https://facebook.github.io/react-native/docs/getting-started.html#content
I am using windows 8.
I have print npm install -g react-native-cli. Then
react-native init AwesomeProject
cd AwesomeProject
Then I have read that on windows I can't use this command react-native run-android so I print node node_modules/react-native/packager/packager.js
as suggested here https://facebook.github.io/react-native/docs/linux-windows-support.html#content
And I get the following output:
Error: Cannot find module
'C:\Windows\System32\AwesomeProject\node_modules\react
-native\packager\packager.js'
at Function.Module._resolveFilename (module.js:337:15)
at Function.Module._load (module.js:287:25)
at Function.Module.runMain (module.js:457:10)
at startup (node.js:136:18)
at node.js:972:3
Myawesomeproject folder has 2 files
npm-debug.log and package.json
So I feel like something went wrong. Ho can I fix this?
It seems like npm is not installed correctly on your machine. You may test it by calling npm install in the generated directory. If it runs successfully and the node_modules folder in that directory is filled your are good to go. You should then run the react-native init command again so it can generate everything correctly.

Cordova android build fails immediately [Error: spawn EACCES]

I am just getting started with with Cordova ( PhoneGap ) and trying to build my first project with it, however I am running into a problem with my compilation step- when I try to build ( in tracking down the problem I broke down the build step into prepare and compile and the former works fine as far as I know ) I see this:
~/Projects/MyProject$ cordova compile android
Compiling app on platform "android" via command "/media/glenatron/local disk/Projects/Cordova/MyProject/platforms/android/cordova/build"
{ [Error: spawn EACCES] code: 'EACCES', errno: 'EACCES', syscall: 'spawn' }
Now from what I can tell this is a permissions problem, but having no Node or Cordova experience yet I am at a loss as to how to troubleshoot it. It looks as though it is trying to spawn another process - maybe the Android SDK? - and it is failing.
Is there a way I can ask Node or Cordova to give me more information on what is going on or is there a log file somewhere that will help me to track down what the problem is?
Edit: I realised cordova has a --verbose switch and when I activated it I get the above output with an additional couple of lines...
Error: spawn EACCES
at errnoException (child_process.js:980:11)
at Process.ChildProcess._handle.onexit (child_process.js:771:34)
Unfortunately, they don't seem to actually give much more information, like which process it can't start.
For me, this has fixed it:
chmod 777 /Applications/Android\ Studio.app/Contents/gradle/gradle-2.2.1/bin/gradle
It's a permission issue, just execute:
chmod 777 "/media/glenatron/localdisk/Projects/Cordova/MyProject/platforms/android/cordova/build"
That should fix the problem.
Using verbose like Solidak suggested works.
cordova build --release --verbose android
The last command was to access /platforms/android/gradlew so i chmod +x that file and it worked.
Its different for every one, I guess. Running --verbose would give you the file that Cordova needs access to. From there you can chmod 777 <file>. The command you should run to figure out the inaccessible file looks like this: cordova build --release --verbose android
I was facing the same issue. In my case, I had put the sample cordova project on a different ext3 partition than home folder. Since the partition was not NTFS, permissions shouldn't have been a problem. But when I tried all suggested methods (changing permissions, making everything executable), none of them worked. This problem went away as soon as I created the sample cordova folder in my home partition.
For MAC users change the name from "Android Studio" to AndroidStudio. My cordova build was taking back slash() in name of android studio so i changed the name of app.
It is working for me.

Categories

Resources