How to link packages in react-native - android

I am getting these errors while running my app.
bundling failed: Error: Unable to resolve module ` react-native-screens` from `node_modules/react-navigation-tabs/src/navigators/createBottomTabNavigator.js`
How to solve this error. I just reinstalled the node modules and again installed the modules. Can someone help?

Depending on your react native version for >= 0.60.x just run :
npm install react-native-screens
and for <= 0.59.9 :
npm install react-native-screens
react-native link react-native-screens

as of react native >= 0.60 there is no need for manually linking
so for your issue
remove node_modules folder
and then
npm install
npm install react-native-screens
or
yarn
yarn add react-native-screen
close the terminal
clean the project => cd android => ./gradlew clean
remove the old app
then re run

Run following commands
npm install react-native-screens
react-native link react-native-screens

Related

error on react-native run-android while installation , can't run in windows 10

I am currently running Windows 10. I followed all the steps on the documentation regarding android development on https://facebook.github.io/react-native/docs/getting-started but got the following error:
I tried uninstalling and cleaning my installation directories twice, but still it has the same error.
I really want to setup my development environment for React Native, but I don't know what action to do next.
The versions I'm using (latest):
react-native-cli: 2.0.1
react-native: 0.56.0
Any help would be greatly appreciated. Thanks!
EDIT - here's the output of react-native start
I think this is a bug in version 0.56. The "solution" is to find the correct combination of dependencies' versions.
Try this commands one by one correctly ...
react-native init AwesomeProject
cd AwesomeProject
react-native run-android
npm uninstall react-native
npm install --save react-native#0.55.4
react-native run-android
npm install --save babel-core#latest babel-loader#latest
npm uninstall --save babel-preset-react-native
npm install --save babel-preset-react-native#4.0.0
react-native run-android

How to initialize React Native project

Please note I have read the documentation and I'm referencing the point where the error happens as well as the steps I have taken. Please don't advice me to follow the instructions that I have already indicated I have followed.
After following the documentation of React Native to the best of my ability, I have been unable to get React Native to run. I have installed jdk, node, and Android Studio as instructed (using Chocolatey and links). The Android Emulator runs from Android Studio. I'm using npm version 6.1.0, node version 8.4.0, jdk 8, Android Studio 3.1.3. The error I get after react-native init AwesomeProject is SyntaxError: Unexpected token import. What did I do wrong? How can I fix this? Running react-native run-android also gives the same error.
To be clear, I'm in the proper directory. ANDROID_HOME is set to the proper sdk folder. There is a heading, Running your React Native application, and running the first command leaves me with the error, but I don't get an error before that point.
install npm
install react native cli => npm install -g
react-native-cli && npm install -g react-native (admin or sudo)
react-native init MyProject
cd Myproject
react-native run-ios or run-android
Update node to the latest version.
npm install -g react-native-cli.
npx react-native init newProject.
Since you install react native globally you don't need to use npx packages anymore just try
react-native init newProject
Assuming that you have Node 14 LTS or greater installed, you can use npm to install the Expo CLI command line utility:
npm install -g expo-cli
Then run the following commands to create a new React Native project called "AwesomeProject":
expo init AwesomeProject
cd AwesomeProject
npm start
Source: React Native Environment Setup

the development server returned response error code 500 - react native - ./configs/main

I got this error when i tried to make hello-world sample:
react-native init hello_world
cd hello_world
react-native run-android
Even when I ran:
npm install -g react-native-git-upgrade
react-native-git-upgrade
I got same error on commend line console.
I've searched and tried many solutions but it doesn't seem to work:
Example:
* upgrade react-native
* using watchman watchman watch-del-all
* remove node_modules
* clean cache npm cache cleanor npm start -- --reset-cache
Operation: Window 8
react-native-cli: 2.0.1
react-native: 0.44.2 ( tried 0.47.1 too )
Android: Simulator Nexus5X
Thank you all in advance!
Delete babel-preset-react-native folder inside node_modules and then install older version 2.1.0 of this library with npm install babel-preset-react-native#2.1.0 --save-dev.
In case if someone is using react-native: 0.57.1 or the latest one,babel-preset-react-native has been replaced by metro-react-native-babel-preset. if you still get 500 error while connecting to the device do the below step and I guess things will be fine
npm add #babel/runtime
npm install
Downgrade the following:
react-native init Project
cd Project
npm uninstall react-native
npm install --save react-native#0.55.4
npm uninstall --save babel-preset-react-native
npm install --save babel-preset-react-native#4.0.0
react-native run-android
For me it's about the react native version. I just install the new version of react native "0.59.2" then i downgrade to previous version to "0.55.2", and everything works fine.

installing npm modules removes react-native-cli

I have a react-native project where I install modules using
npm install some-module -save
package.json includes react-native-cli
Now, every time I do this the command react-native run-android is not available anymore. I have to run
yarn add react-native-cli
in order for it to be available again. Also, the gradle file of some modules get out of sync when I do this which means running Android Studio and updating these.
I find this very confusing. Earlier in the project, I was only using npm and had no problems.
i think you can try this
npm install -g <package> --save

npm WARN react-native-maps#0.14.0 requires a peer of react#>=15.4.0 but none was installed

Problem
I'm trying to install react-native-maps by Airbnb in my project. Installation instructions:
airbnb/react-native-maps/installation
When I run the following command in cmd: npm install react-native-maps --save
This is what I get:
`-- react-native-maps#0.14.0
npm WARN react-native-maps#0.14.0 requires a peer of react#>=15.4.0 but none was installed.
Ignoring this if I proceed with further installation, and run the following command: react-native link react-native-maps
This is what I get:
Scanning 561 folders for symlinks in C:\RNProjects\Mapp\node_modules (39ms)
rnpm-install info Linking react-native-maps ios dependency
rnpm-install info iOS module react-native-maps has been successfully linked
^As we can see, only iOS related maps modules get installed. On checking the project directory, I was able to validate that no android related module was installed.
Troubleshooting
Here's the list of thing I tried to resolve the issue, but none of them worked.
Tried installing npm install react#15.4.0 --save
Got these warnings:
npm WARN react-native#0.43.3 requires a peer of react#16.0.0-alpha.6 but none was installed.
npm WARN react-test-renderer#16.0.0-alpha.6 requires a peer of react#^16.0.0-alpha.6 but none was installed.
So, in order to resolve this, I tried installing react#16.0.0-alpha.6 with: npm install react#16.0.0-alpha.6.
I got the same message again:
npm WARN react-native-maps#0.14.0 requires a peer of react#>=15.4.0 but none was installed.
Tried updating react-native npm update react-native.
Still getting the same warning message.
Tried installing the latest version of npm: npm install npm#latest -g.
Didn't work.
Additional Information
react-native: 0.43.3
react-native-cli: 2.0.1
Platform: Android
Development Operating System: Windows 10 OS
Here's how I was able to solve this (chronological order):
Deleted node_module directory from the project
npm cache clean
Modified package.json with: "react":"~15.4.1"; "react-native":"0.42.3"; "react-test-renderer":"15.4.1"
npm install all module
npm install
npm i react-native-maps#0.12.5 --S
react-native link react-native-maps
Once I do this, it's successfully able to link the android and ios react-native-modules to the project.
Note: Before running the react-native run-android command,
Run: cd android && gradlew clean && cd .. && react-native run-android.
This will clean the gradle before running and help in avoiding any errors.
You can try:
delete node_module, npm cache clean;
modify package.json
"react": "~15.4.1","react-native": "0.42.3","react-test-renderer": "~15.4.1",
npm install all module;
done ;)
Here is how i was able to solve this same issue:
I deleted the node_module folder (You can verify npm cache: npm cache verify)
I actually changed the package.json file to the following:
"react": "~15.4.1","react-native": "0.42.3","react-test-renderer": "~15.4.1"
But that triggered other error on my side; So i put them back to their initial
values:
a. "react": "17.0.1",
b. "react-native": "0.64.0",
c. "react-test-renderer": "17.0.1"
npm install all module
npm install
npm audit fix --force
npm i react-native-maps#0.12.5 --S
react-native link react-native-maps
At this point I opened 2 terminals:
a. Terminal 1: react-native start
b. Terminal 2: react-native run-android or yarn android

Categories

Resources