child_process could not be found within the project-- react native - npm

Created a new project on react native 0.61.4
Copied the screens and functionality from previous project which was on 0.55.4.
Everything is build but the bundling is failed with the following errors:
error: bundling failed: Error: Unable to resolve module child_process from node_modules\jest-changed-files\node_modules\execa\index.js: child_process could not be found within the project.
Error: Bundling failed
Package.json:
{
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"execa": "^3.2.0",
"jest-changed-files": "^24.9.0",
"mockjs": "^1.1.0",
"moment": "^2.24.0",
"native-base": "^2.13.8",
"react": "16.9.0",
"react-moment": "^0.9.6",
"react-month-picker": "^1.3.11",
"react-native": "0.61.4",
"react-native-datepicker-dialog": "0.0.9",
"react-native-gesture-handler": "^1.5.0",
"react-native-image-slider-show": "^1.0.3",
"react-native-keyboard-aware-scroll-view": "^0.9.1",
"react-native-linear-gradient": "^2.5.6",
"react-native-modal-datetime-picker": "^7.6.0",
"react-native-month-selector": "^1.4.0",
"react-native-responsive-screen": "^1.3.0",
"react-native-simple-table": "0.0.3",
"react-native-slideshow": "^1.0.1",
"react-native-spinkit": "^1.5.0",
"react-native-svg": "^9.13.3",
"react-native-swipe-gestures": "^1.0.4",
"react-navigation": "^4.0.10",
"react-navigation-stack": "^1.10.3",
"react-time-picker": "^3.7.2"
},
"devDependencies": {
"#babel/core": "^7.6.4",
"#babel/runtime": "^7.6.3",
"#react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^24.9.0",
"eslint": "^6.6.0",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.57.0",
"path": "^0.12.7",
"react-test-renderer": "16.9.0"
},
"jest": {
"preset": "react-native"
},
"browser": { "child_process": false }
}
Any help would be appreciated!

Please clean your project then run project.Some library is not adding by autolinking fearure so please check and add properly like firebase library need to add manually.I attached some screenshot so please check.

Check in any of the files you were working on recently and be sure you are not mistakenly importing child_process somewhere. In my case it was process as shown in the image above.

Related

react native apk build fail

I have been trying to make an APK of my react native app, but don't know what problem is causing the APK build to fail. I am using the command gradlew assembleRelease to make APK
Following below I have given information about my app and error, please comment if any more information is required.
package.json:
{
"name": "appName",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
},
"dependencies": {
"#react-native-community/datetimepicker": "3.5.2",
"#react-navigation/native": "5.9.2",
"#react-navigation/stack": "5.14.2",
"formik": "^2.2.9",
"moment": "^2.29.4",
"react": "17.0.2",
"react-native": "0.68.2",
"react-native-confirmation-code-field": "7.2.0",
"react-native-countdown-component": "^2.7.1",
"react-native-gesture-handler": "1.9.0",
"react-native-mask-input": "1.2.1",
"react-native-modal-selector-searchable": "^2.1.4",
"react-native-safe-area-context": "3.1.9",
"react-native-screens": "2.17.1",
"react-native-svg": "12.1.0",
"react-native-video": "^5.2.1",
"yup": "^0.32.11"
},
"devDependencies": {
"#babel/core": "^7.20.12",
"#babel/runtime": "^7.20.13",
"#react-native-community/eslint-config": "^3.2.0",
"#types/react": "^18.0.27",
"#types/react-native": "^0.71.2",
"babel-jest": "^29.4.1",
"eslint": "^8.33.0",
"jest": "^29.4.1",
"metro-react-native-babel-preset": "^0.75.0",
"prettier": "^2.8.4",
"react-native-svg-transformer": "^1.0.0",
"react-test-renderer": "17.0.2",
"typescript": "^4.9.5"
},
"jest": {
"preset": "react-native"
}
}
error while building APK:
> Task :react-native-screens:generateReleaseRFile FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-screens:generateReleaseRFile'.
> Could not resolve all files for configuration ':react-native-screens:releaseCompileClasspath'.
> Failed to transform react-native-0.71.0-rc.0-release.aar (com.facebook.react:react-native:0.71.0-rc.0) to match attributes {artifactType=android-symbol-with-package-name, com.android.build.api.attributes.BuildTypeAttr=release, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
> Could not find react-native-0.71.0-rc.0-release.aar (com.facebook.react:react-native:0.71.0-rc.0).
Searched in the following locations:
https://repo.maven.apache.org/maven2/com/facebook/react/react-native/0.71.0-rc.0/react-native-0.71.0-rc.0-release.aar
This issue was caused by a wrong reference for React Native android artifacts on Maven repository - React Native Core Team already provided the patch - https://github.com/facebook/react-native/issues/35210

React Native app rejected for QUERY_ALL_PACKAGES

So, here's a head scratcher (at least, it is for me).
Issue found: Less broad app-visibility method should be used.
We are unable to approve your app’s use of QUERY_ALL_PACKAGES permission because >the declared task can be done with a less broad app-visibility method.
One suggested method is to declare your app's need for specific package >visibility using the element. You may refer to the common use cases.
But here's where it gets weird...the permission is not on my merged manifest, or anywhere in my code when searched in VSCode. I've tried every fix going but cannot trace where this permission is being generated or where it is even present!
It has been rejected three times now. Appeals lead to no-where so it must be something in the code.
package.json below.
Any help appreciated. Thanks in advance.
{
"name": "MY APP",
"version": "1.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"#react-native-async-storage/async-storage": "^1.17.7",
"#react-native-community/netinfo": "^9.3.0",
"#react-native-firebase/app": "^15.1.1",
"#react-native-firebase/auth": "^15.1.1",
"#react-native-firebase/firestore": "^15.1.1",
"#react-native-firebase/messaging": "^15.1.1",
"#react-navigation/bottom-tabs": "^6.3.2",
"#react-navigation/native": "^6.0.11",
"#react-navigation/native-stack": "^6.7.0",
"#rneui/base": "^4.0.0-rc.5",
"#rneui/themed": "^4.0.0-rc.5",
"deprecated-react-native-prop-types": "^2.3.0",
"react": "18.0.0",
"react-native": "0.69.1",
"react-native-bootsplash": "^4.2.3",
"react-native-camera": "^4.2.1",
"react-native-confetti-cannon": "^1.5.2",
"react-native-game-engine": "^1.2.0",
"react-native-gesture-handler": "^2.5.0",
"react-native-linear-gradient": "^2.6.2",
"react-native-offline": "^6.0.0",
"react-native-permissions": "^3.5.0",
"react-native-promise-rejection-utils": "^0.0.1",
"react-native-qrcode-scanner": "^1.5.5",
"react-native-qrcode-svg": "^6.1.2",
"react-native-rename": "^2.9.0",
"react-native-restart": "^0.0.24",
"react-native-safe-area-context": "^4.3.1",
"react-native-screens": "^3.15.0",
"react-native-svg": "^12.3.0",
"react-native-toast-message": "^2.1.5",
"react-native-vector-icons": "^9.2.0",
"react-native-webview": "^11.22.7",
"react-uuid": "^1.0.2",
"rn-scratch-card": "^1.0.0-beta7"
},
"devDependencies": {
"#babel/core": "^7.12.9",
"#babel/runtime": "^7.12.5",
"#react-native-community/eslint-config": "^2.0.0",
"babel-jest": "^26.6.3",
"eslint": "^7.32.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.70.3",
"react-test-renderer": "18.0.0"
},
"jest": {
"preset": "react-native"
}
}

Unable to resolve module `assert` from `node_modules\#jest\console\build\BufferedConsole.js`: assert could not be found within the project

I started getting this error all of a sudden on my working react-native app. I have tried all possible solutions available on other questions like clearing cache and all but nothing worked for me.
Even I tried to run my previous working apps and creating new app but getting the same error for all.
Please let me know if you need any further details to look into the issue.
Any kind of help will be much appreciated.
Thanks in advance.
Below is my package.json
{
"name": "MyApp",
"version": "0.0.1",
"private": true,
"rnpm": {
"assets": [
"./assets/fonts"
]
},
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint .",
"clean": "react-native-clean-project"
},
"dependencies": {
"#react-native-community/masked-view": "^0.1.10",
"#react-navigation/bottom-tabs": "^5.9.1",
"#react-navigation/drawer": "^5.9.2",
"#react-navigation/material-bottom-tabs": "^5.2.18",
"#react-navigation/native": "^5.7.5",
"#react-navigation/stack": "^5.9.2",
"react": "16.13.1",
"react-native": "0.63.2",
"react-native-clean-project": "^3.4.0",
"react-native-gesture-handler": "^1.8.0",
"react-native-reanimated": "^1.13.1",
"react-native-safe-area-context": "^3.1.8",
"react-native-screens": "^2.11.0",
"react-native-splash-screen": "^3.2.0",
"react-native-tab-view": "^2.15.1",
"react-native-vector-icons": "^7.1.0",
"react-native-webview": "^10.9.0"
},
"devDependencies": {
"#babel/core": "^7.8.4",
"#babel/runtime": "^7.8.4",
"#react-native-community/eslint-config": "^1.1.0",
"babel-jest": "^25.1.0",
"eslint": "^6.5.1",
"jest": "^25.1.0",
"metro-react-native-babel-preset": "^0.59.0",
"react-test-renderer": "16.13.1"
},
"jest": {
"preset": "react-native"
}
}

ReactNative Code not running on WEB (ReactCLI)

I am new to ReactNative world,
I am using ReactCLI (No Expo)
My Code running fine on Android Simulator, but don't know why it is not executing on WEB. (See attachment). I am using Windows 10.
Additionally,
I got URL (why my code not run in react-native code in web) that saying - It doesn't work. But as per the FACEBOOK guideline "React Native is used to develop applications for Android, iOS, Web and UWP by enabling developers to use React along with native platform capabilities."
So, what I am missing??
Below is my Package.JSON
"scripts": {
"android": "npx react-native run-android",
"ios": "react-native run-ios",
"start": "npx react-native start --reset-cache",
"test": "jest",
"lint": "eslint .",
"build-android": "cd ./android && ./gradlew clean && ./gradlew assembleRelease"
},
"pre-commit": [
"lint"
],
"dependencies": {
"#react-native-community/masked-view": "^0.1.10",
"#react-navigation/drawer": "^5.8.0",
"#react-navigation/native": "^5.4.3",
"#react-navigation/stack": "^5.4.0",
"axios": "^0.19.2",
"react": "16.11.0",
"react-native": "0.62.2",
"react-native-gesture-handler": "^1.6.1",
"react-native-linear-gradient": "^2.5.6",
"react-native-paper": "^3.10.1",
"react-native-reanimated": "^1.9.0",
"react-native-safe-area-context": "^2.0.3",
"react-native-screens": "^2.8.0",
"react-native-splash-screen": "^3.2.0",
"react-native-svg": "^12.1.0",
"react-native-unimodules": "^0.9.1",
"react-native-vector-icons": "^6.6.0",
"react-navigation": "^4.3.9"
},
"devDependencies": {
"#babel/core": "^7.10.0",
"#babel/runtime": "^7.10.0",
"#react-native-community/eslint-config": "^1.1.0",
"babel-jest": "^26.0.1",
"eslint": "^7.1.0",
"jest": "^26.0.1",
"metro-react-native-babel-preset": "^0.59.0",
"pre-commit": "^1.2.2",
"react-test-renderer": "16.11.0"
},
"jest": {
"preset": "react-native"
}
}

react-native release apk giving error in alert box {"line":132,"column":7285,"sourceURL":"index.android.bundle"}

I am new to react-native and creating apk using command sudo react-native run-android --variant=release app is working fine on usb debbuging, but when i am creating apk and run it on mobile device it gives error alert box
{"line":132,"column":7285,"sourceURL":"index.android.bundle"}
I am sharing package.json and babel.config.json
{
"name": "ReactNativeApp",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"#bam.tech/react-native-snap-carousel": "^3.2.3",
"#react-native-community/datetimepicker": "^2.2.2",
"#react-native-community/masked-view": "^0.1.6",
"#react-navigation/drawer": "^5.1.0",
"#react-navigation/native": "^5.0.2",
"#react-navigation/stack": "^5.0.2",
"#twotalltotems/react-native-otp-input": "^1.2.0",
"core-js": "^3.6.4",
"react": "16.9.0",
"react-native": "0.61.5",
"react-native-app-intro-slider": "^3.0.0",
"react-native-bootsplash": "^0.1.0",
"react-native-countdown-component": "^2.6.0",
"react-native-datepicker": "^1.7.2",
"react-native-device-info": "^5.5.3",
"react-native-drawer": "^2.5.1",
"react-native-gesture-handler": "^1.6.0",
"react-native-image-picker": "^2.3.1",
"react-native-interactive-image-gallery": "^0.1.2",
"react-native-masonry-list": "^2.16.1",
"react-native-material-dialog": "^0.7.7",
"react-native-material-dropdown": "^0.11.1",
"react-native-modal": "^11.5.4",
"react-native-modal-datetime-picker": "^8.5.1",
"react-native-modal-dropdown": "^0.7.0",
"react-native-modals": "^0.19.9",
"react-native-photo-upload": "^1.3.0",
"react-native-reanimated": "^1.7.0",
"react-native-safe-area-context": "^0.7.2",
"react-native-screens": "^2.0.0-beta.2",
"react-native-snap-carousel": "^3.8.4",
"react-native-sqlite-storage": "^4.1.0",
"react-native-tab-view": "^2.13.0",
"react-native-textarea": "^1.0.3",
"react-native-vector-icons": "^6.6.0",
"react-navigation": "^4.1.1",
"react-navigation-drawer": "^2.3.4"
},
"devDependencies": {
"#babel/core": "^7.8.4",
"#babel/runtime": "^7.8.4",
"#react-native-community/eslint-config": "^0.0.7",
"babel-jest": "^25.1.0",
"eslint": "^6.8.0",
"jest": "^25.1.0",
"metro-react-native-babel-preset": "^0.58.0",
"react-test-renderer": "16.9.0"
},
"jest": {
"preset": "react-native"
}
}
and babel.config.json
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
};
If you are using APIs call in the android and uses HTTP calls which is not secure then this problem will occur in Android API >= 28.
This problem comes in API < 28 but android handles it but now after API 28 they are not handling it rather want developers to use HTTPS api calls for added security. As android versions are coming they are more towards security.
But if you still want to use HTTP API calls in your android app, be it in react native or any other you have to add this in androidmanifest.xml file
<application
android:usesCleartextTraffic="true"
.......>
</application>
The value of usesCleartextTraffic is by default set to false in API > 28.So we have to manually set it to true to make it working.