In my React Native with TypeScript project, I wanted to install dependencies.
To install Testing Libraries I’ve used this command:
npm install @testing-library/react-native @testing-library/jest-native –save-dev
**But it's giving me this error:**
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: [email protected]
npm error Found: [email protected]
npm error node_modules/react
npm error react@"18.2.0" from the root project
npm error peer react@">=16.8.0" from @testing-library/[email protected]
npm error node_modules/@testing-library/react-native
npm error dev @testing-library/react-native@"*" from the root project
npm error 1 more (react-native)
npm error
npm error Could not resolve dependency:
npm error peer react@"^18.3.1" from [email protected]
npm error node_modules/react-test-renderer
npm error peer react-test-renderer@">=16.8.0" from @testing-library/[email protected]
npm error node_modules/@testing-library/react-native
npm error dev @testing-library/react-native@"*" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
— I’ve also tried –legacy-peer-deps but, then npm install is not working and I’m not sure what’s wrong.
===> Output of npm ls react-dom:
[email protected] /Users/App
└── (empty)
===> Output of npm ls react:
[email protected] /Users/****/App
├─┬ @testing-library/[email protected]
│ └── [email protected] deduped
├─┬ @testing-library/[email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ ├─┬ @react-native/[email protected]
│ │ └── [email protected] deduped
│ ├─┬ [email protected]
│ │ └── [email protected] deduped
│ └── [email protected] deduped
└── [email protected]
I’ve tried –legacy-peer-deps, it’s working temporary but when I try to add ESLint, it’s again giving me error.
npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: @testing-library/[email protected]
npm error Found: [email protected]