Library is not importing - javascript

I am trying to import the react-navigation library in my react native project.
But it is giving me this error:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: IbexCrypto#0.0.1
npm ERR! Found: react#17.0.1
npm ERR! node_modules/react
npm ERR! react#"17.0.1" from the root project
npm ERR! peer react#"*" from #react-navigation/stack#5.14.3
npm ERR! node_modules/#react-navigation/stack
npm ERR! #react-navigation/stack#"*" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^16.0" from #react-native-community/masked-view#0.1.10
npm ERR! node_modules/#react-native-community/masked-view
npm ERR! peer #react-native-community/masked-view#">= 0.1.0" from #react-navigation/stack#5.14.3
npm ERR! node_modules/#react-navigation/stack
npm ERR! #react-navigation/stack#"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\me\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\me\AppData\Local\npm-cache\_logs\2021-03-17T15_24_47_867Z-debug.log
It is also giving me the same error while I try to import some other libraries too.
Previously when I import the navigation library in my old project it works fine but now it is giving me this error.
Kindly, someone tells me why this error is showing. And how to resolve the issue and how to avoid the same problem in the future.
I will be very thankful if someone helps me as I am a relative beginner in development and do not know the logic of this error.

use commond
npm install #react-navigation/native
for import the react-navigation library

You have a dependency conflict! It means that you have an incorrect and potentially broken dependency.
Try this first:
rm -rf node_modules/
npm install
This command removes the node_modules folder and then installs the dependencies you have in your package.json
If it doesn't work, try to run npm install with the command --force or --legacy-peer-deps.
In your case:
npm install #react-navigation/native --force
or: npm install #react-navigation/native --legacy-peer-deps
Description of the commands:
--force: forces npm install to install the dependencies you want to install.
-legacy-peer-deps: --legacy-peer-deps: ignore all peerDependencies when installing.
These commands it's necessary in some cases but as standard npm install should be enough to install the dependencies from your package.json file.

For your issues, this two command may works
npm install --legacy-peer-deps
or
npm install --force
React navigation command in version 3 and 4
npm install —-save react-navigation
There are some minor changes in navigation 4
React navigaiton
React navigation command in version 5
npm install #react-navigation/native
You can import like below code
import { createAppContainer } from "react-navigation";

please refer official docs for react-navigation and install all the necessery dependency from here:
https://reactnavigation.org/docs/getting-started
after installing dependency run
react-native start --reset-cache
and then
react-native run-android

Related

VUE install - unable to resolve dependency tree

I pull my project from other computer, it works fine there, but when i npm install on this machine it got this error. can i have some clue about how to fix this and what I need to do to avoid this kind of problem in the future.
npm ERR! Found: vue#3.2.45
npm ERR! node_modules/vue
npm ERR! vue#"^3.2.45" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue#"^2.5.17" from element-ui#2.15.12
npm ERR! node_modules/element-ui
npm ERR! element-ui#"^2.4.5" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
I've tried installing vue, update npm to v18, all requirement are supposed to be fulfilled
You are installing ElementUI version 2.15.12 - which supports only Vue version 2 but your Vue is version 3.
Either install ElementPlus or downgrage Vue 3 to Vue 2.

npx create-react-app show error when installing

npx create-react-app shoing eror whent installing, please help me how to solve this
problem. my nodejs version is v16.14.2 and npm version is 8.5.0
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
added 1354 packages in 1m
171 packages are looking for funding
run `npm fund` for details
Initialized a git repository.
Installing template dependencies using npm...
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: instagram-clone#0.1.0
npm ERR! Found: react#18.0.0
npm ERR! node_modules/react
npm ERR! react#"^18.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"<18.0.0" from #testing-library/react#12.1.5
npm ERR! node_modules/#testing-library/react
npm ERR! #testing-library/react#"^12.0.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /home/psn/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/psn/.npm/_logs/2022-04-12T07_12_21_032Z-debug-0.log
`npm install --no-audit --save #testing-library/jest-dom#^5.14.1 #testing-
library/react#^12.0.0 #testing-library/user-event#^13.2.1 web-vitals#^2.1.0` failed
Sounds like you are running npx create-react-app command in a project that already includes react. Try running npm install instead.
If that does not work try to remove your node_modules folder and run npm install again.
You can try the following:
Delete both node_modules and package-lock.json
Run npm i web-vitals --save-dev
Run npm install

Problem in Installing Material ui with next js (with and without typescript) error [duplicate]

This question already has answers here:
Fix the upstream dependency conflict installing NPM packages
(15 answers)
Closed 11 months ago.
im new to react and next js so sorry for my idiotic question,
im trying to install material ui in a new next js app
(i used "npx create-next-app#latest"),
and im using the Material ui docs and the ts section
(https://mui.com/guides/typescript/#main-content)
i got the following error in cli / terminal:
npm install #mui/material #emotion/react #emotion/styled
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! peer react#">=16.8.0" from #emotion/react#11.8.2
npm ERR! node_modules/#emotion/react
npm ERR! #emotion/react#"*" from the root project
npm ERR! peerOptional #emotion/react#"^11.5.0" from #mui/material#5.5.3
npm ERR! node_modules/#mui/material
npm ERR! #mui/material#"*" from the root project
npm ERR! 1 more (#emotion/styled)
npm ERR! 1 more (#emotion/styled)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^17.0.0" from #mui/material#5.5.3
npm ERR! node_modules/#mui/material
npm ERR! #mui/material#"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
i have tried to use the material ui component and got a compiler error,
even though i have tried in a nextjs (without ts and with)
and with the flags: --force, or --legacy-peer-deps
please help! a lot of thanks in advance! i just need to start my project!
install material ui in next-js with and without typescript
If I had this problem I would have deleted package.json and installed it again and after that I try to install Material. Did you try this?
Run this command. Just worked for me.
npm install #mui/material #emotion/react #emotion/styled --force
I also deleted my node_modules and did another install to be sure. and it found 0 vulnerabilities.

How to fix npm ERR! Cannot find module './src/table' when running npx create-react-app

On Windows 10, I am getting this error: npm ERR! Cannot find module './src/table' when trying to start a new project with
npx create-react-app my-app. I searched around but really couldn't find anything about this module './src/table'
Here is the log:
$ npx create-react-app my-app
Creating a new React app in D:\reandomDirectory.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module './src/table'
npm ERR! Require stack:
npm ERR! - C:\Users\MyPC\AppData\Roaming\nvm\v12.16.1\node_modules\npm\node_modules\cli-table3\index.js
npm ERR! - C:\Users\MyPC\AppData\Roaming\nvm\v12.16.1\node_modules\npm\node_modules\npm-audit-report\reporters\detail.js
npm ERR! - C:\Users\MyPC\AppData\Roaming\nvm\v12.16.1\node_modules\npm\node_modules\npm-audit-report\index.js
npm ERR! - C:\Users\MyPC\AppData\Roaming\nvm\v12.16.1\node_modules\npm\lib\install\audit.js
npm ERR! - C:\Users\MyPC\AppData\Roaming\nvm\v12.16.1\node_modules\npm\lib\install.js
npm ERR! - C:\Users\MyPC\AppData\Roaming\nvm\v12.16.1\node_modules\npm\lib\npm.js
npm ERR! - C:\Users\MyPC\AppData\Roaming\nvm\v12.16.1\node_modules\npm\bin\npm-cli.js
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\MyPC\AppData\Roaming\npm-cache\_logs\2021-05-24T01_01_52_667Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
Deleting generated file... package.json
Deleting my-app/ from D:\reandomDirectory
Done.
I have version 3.4.1 globally installed and even if I try to uninstall it I get the same error.
Also, the directory where I am trying to start the project is completely empty.
Any idea of how I could fix this?

Module not found: Can't resolve 'moment' in 'node_modules\react-moment\dist' in reactjs

I have installed react-moment 'npm i react-moment'. It is installed in the directory node_modules and dependency added in the package.json file. Every thing is correct. But when I import
import Moment from 'react-moment'
then it shows
Module not found: Can't resolve 'moment' in 'node_modules\react-moment\dist'
But there is nothing wrong with this directory, I haven't modified the files inside react-moment directory in node_modules. Just after installing the package, when I import the package
import Moment from 'react-moment'
Then it shows the error.
moment is a peer dependency of react-moment, which mean you have to install moment in you project as well (it doesn't ship with its own version of moment).
npm i --save moment
Worked for me:
npm install --save moment
npm install --save react-moment
npm install --save moment-timezone
:)
I sorted it out by adding the '--legacy-peer-deps' argument to the end of the command as the error message shows:
npm ERR! Conflicting peer dependency: #angular/common#13.3.12
npm ERR! node_modules/#angular/common
npm ERR! peer #angular/common#">=13.0.0 <14.0.0" from #ng-select/ng-select#8.3.0
npm ERR! node_modules/#ng-select/ng-select
npm ERR! #ng-select/ng-select#"^8.0.0" from #ng-matero/extensions#13.1.0
npm ERR! node_modules/#ng-matero/extensions
npm ERR! #ng-matero/extensions#"^13.1.0" from the root project
npm ERR! #ng-select/ng-select#"^8.1.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /Users/yimin/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/yimin/.npm/_logs/2022-12-01T14_08_17_585Z-debug-0.log
npm install --save moment --legacy-peer-deps
I was having same issue with reac-datetime package and this one worked for me:
npm install --save moment
If you are working with Timezone features make sure that you have installed the timezone package as well. if not paste the below npm code.
npm install --save moment-timezone

Categories