Why can't I install the React Native Testing library? - react-native

I'm new to app testing and have started delving into this topic since yesterday. I wanted to write tests for my React Native app and tried to install React Native Testing Library with this command:
npm install --save-dev #testing-library/react-native #testing-library/jest-native
Then I ran into the following problem:
I tried to find a solution to this problem in Google, but I did not succeed. As far as I understand, the problem lies in the dependencies?
Please tell me what can I do in this case?
P.S. I tried to create a completely clean project with expo init, tried to install the library but got exactly the same error

Hit the same issue and didn't want to update everything at the moment so I solved the issue by running a suggestion on the npm error output:
npm install --save-dev #testing-library/react-native --legacy-peer-deps
It worked for me

it looks like you are running into a conflict with your react version dependencies. Please check the named modules for required packages they depend on.
Please have a look with: npm outdated and then maybe try to update your settings via npm update
also take a look here if you want: updating npm dependencies

you need to update react version after updating just install the latest version of testing-library

Related

How to upgrade all libraries in an old react native project?

I have some experience in react native but I am relatively new to the field. I have cloned a react native project but it is very old and it contains a lot of libraries that are also either depricated or conflicting. I want to make the project compile as its not compiling now too because of the conflicting library issues. Any help or guidance regarding what i should do to make it work?
I have tried a number of things like deleting node modules and package-lock and running npm install but it doesnt run so I used --force but it still didnt make it work then I used npm install --legacy-peer-deps and it still didnt work.
i tried to upgrade the specific libraries that were mentioned in the errors but they also failed.
right now I have no idea what should be done.
As of npm version 5.2.0+, we can update all our dependencies without installing any additional packages.
Run the command in the root of your project:
npx npm-check-updates -u && npm i
"npx npm-check-updates -u" the command just updates the package.json that’s why we need tonpm i after the update the package.json.
for more info click here

Warning: Invalid version react-native#0.64.2 for expo sdkVersion 43.0.0. Use react-native#0.64.3

I am working on an expo project and everything is working fine, but I began to get a warning message when android is building as
Warning: Invalid version react-native#0.64.2 for expo sdkVersion 43.0.0. Use react-native#0.64.3
The app is still running fine but I don't how to fix this error yet and I want to know if it won't cause an issue later.
I have tried to run npx react-native upgrade 0.64.3 but it didn't work, I got this error
info Fetching diff between v0.64.2 and v0.64.3... error Fetch request
failed with status 404: 404: Not Found. error Failed to fetch diff for
react-native#0.64.3. Maybe it's not released yet?
changing the version of react-native manually in the package.json and run expo install worked for me
I use the expo doctor command it allows diagnose issues with the project.
I would recommend using the expo upgrade command. It upgrades the project packages and config for the given SDK version.
More to find here.
I just faced the same issue. Basically it's telling you should use a higher version of your react-native. I solved it just by updating it to the specified version.
npx react-native upgrade 0.64.3
More info here.
Cheers,
If as in my case one need a specific version of react-native, let's say older because some legacy dependencies in a particular project that for some reason can't be upgrade, then change the version in the package.json won't work.
What worked as the cli suggested is to use:
expo doctor --fix-dependencies
That installed the correct lower version of react-native
To find out actual problems run this command :
expo doctor
To solve all problems regarding package conflicts run this command:
expo doctor --fix-dependencies
Use sudo on Unix based OS if you have permission issue to run those commands.
To solve the error, I used the below command:
npm install react-native-clean-project --save-dev
It is a library that allows us to resolve conflicts.
This library is added to your dependencies.
This handles the problem and if it is not the case add this command:
react-native clean-project-auto

Struggling to set up nativebase in a React Expo project

I have tried so many different ways to set nativebase up with expo and am still having an issue. At the moment I'm using the
Getting Started documentation found on the nativebase website.
I first create a new app with expo using
expo init myapp
Then I install nativebase using
npm install native-base --save
Then I finally install the font
expo install expo-font
I even copy the App.js found in the getting started documentation, and after I start the app and try to run it on an emulator I face the below error
Unable to resolve "#expo/vector-icons/Fontisto" from "node_modules\native-base\dist\src\basic\IconNB.js"
Failed building JavaScript bundle.
What am I missing? Coming from .NET world this whole process with dependencies is so painful...
*Edit 1
I'm sure someone will make mention of the fact that the error message mentions #expo/vector-icons and I have not installed that. When running before I install this package I get that error, and after I install the mentioned package I still face the exact same error.
Please try with this version of native base :
npm i --save-exact native-base#2.13.8
Expo should release a version with that version .
Hope it helps. feel free for doubts
We can run the below command with Expo
npm i --save-exact native-base#2.13.8
Still this version is not available, but its working, really don't know why?

Error while running the existing React Native project

So I'm opening my the existing React Native project. This is the procedure on how I opened my existing React Native project. 1st step, type the location of my project which is in the "D:\rnprojects\firstproject\". 2nd step, "react-native-start". 3rd step, I opened another cmd then locate it again into my project directory then typed "npm start".
Why when I created this project I didn't get this error just when runnning/opening my existing project.
This the error that I got: (with versions)
There is only simple steps can solve your particular scenario issue quickly.
1) Install the React native cli in your project or globally.
npm install -g react-native-cli
OR
npm install react-native --save
then start your project by using this command
npm start
If any dependencies issue please follow the second solution
2) Please make sure you're installed all dependence
yarn install
OR
npm install
under your project directory
I'm pretty sure your issue will fix by using 1st solution Thanks.
it is simple:
1.npm install
2.react-native run-android
Here I guess you have the RN environment to run already on your side.
cd path_to_project
install packages(there are two following ways to install packages).
2.1 yarn install
2.2 npm install
react-native link(optional - you need to run this command if existing project use RN packages which need to link such as
react-native-vector-icons)
optional(if project use pods) cd ios pod install
react-native run-ios or react-native run-android according to the platform which you want to run on.
I don't think above is perfect instruction give you how to run the existing react-native project, But I am pleasure if give me some hints or help to you.
You can find official guide here
Sometimes npm's cache gets confused and need to reset it by using below command:
npm cache clean --force
Also try below command:
npm install --save-dev react-native-cli
Hope it will help you.

react native doesn't recognize project

I've made a fresh clone of a react-native project which is 100% ok and working. Installed react-native-cli, trying to run react-native start in the project dir, but I get Command start unrecognized. Make sure that you have run npm install and that you are inside a react-native project.
I tried to init a fresh project just to test, and it worked fine, I was able to run react native commands there and everything worked.
It's definitely not an issue with my project because other people work on it as well and it's 100% ok and valid. This is some issue with react native or some other lib, I suppose. What could that be?
I'm using mac os sierra and project's react native version is 0.40.0
So, I've resolved this issue finally, and, to whoever it may concern: the problem wasn't with react-native. The problem was with npm. I was using yarn, and had npm 5 installed on my system. Also I had a postinstall script, which called rn-nodeify. rn-nodeify, in turn, on the final stage called npm (not yarn), and since it was npm 5 I was experiencing an npm 5 bug, which wiped out my modules. The bug is described e.g. here. Downgrading to npm 4 solved this issue for me.