How to resolve a peer dependency issue caused by AWS Amplify? - reactjs

I am having a problem with my react build, maybe related to AWS amplify, but I’m having trouble pinning it down.
When it started, I was able to run my program locally without a problem. I uploaded it to GitHub and my CI/CD setup with amplify tried to build it. Amplify said it broke during the build. At that point I discovered that I couldn’t run npm update.
I’ve been messing with it a lot and may have messed up the environment further. If anyone has any advice I’d really appreciate it.
The error I originally encountered was something like this:
npm WARN ERESOLVE overriding peer dependency
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: react-drag-drop-files#2.3.7
npm ERR! Found: react#16.14.0
npm ERR! node_modules/react
npm ERR! peer react#"18.1.0" from react-native#0.70.6
npm ERR! node_modules/react-native
npm ERR! peer react-native#">=0.56" from react-native-get-random-values#1.7.0
npm ERR! node_modules/react-native-get-random-values
npm ERR! react-native-get-random-values#"^1.4.0" from #aws-sdk/middleware-retry#3.6.1
npm ERR! node_modules/#aws-sdk/middleware-retry
npm ERR! #aws-sdk/middleware-retry#"3.6.1" from #aws-sdk/client-cognito-identity#3.6.1
npm ERR! node_modules/#aws-sdk/client-cognito-identity
npm ERR! 11 more (#aws-sdk/client-comprehend, ...)
npm ERR! peer react-native#"^0.0.0-0 || 0.60 - 0.71 || 1000.0.0" from #react-native-async-storage/async-storage#1.17.11
npm ERR! node_modules/#react-native-async-storage/async-storage
npm ERR! peer #react-native-async-storage/async-storage#"^1.13.0" from #aws-amplify/core#4.0.2
npm ERR! node_modules/#aws-amplify/core
npm ERR! #aws-amplify/core#"4.0.2" from #aws-amplify/analytics#5.0.0
npm ERR! node_modules/#aws-amplify/analytics
npm ERR! 11 more (#aws-amplify/api-graphql, #aws-amplify/api-rest, ...)
npm ERR! 1 more (amazon-cognito-identity-js)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^18.0.0" from react-drag-drop-files#2.3.7
npm ERR! node_modules/react-drag-drop-files
npm ERR! react-drag-drop-files#"^2.3.7" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react#18.2.0
npm ERR! node_modules/react
npm ERR! peer react#"^18.0.0" from react-drag-drop-files#2.3.7
npm ERR! node_modules/react-drag-drop-files
npm ERR! react-drag-drop-files#"^2.3.7" from the root project
Fully uninstalling react-drag-drop-files didn't help either, it just replaced it with another dependency issue;
The suggestions I saw were mostly reinstall after performing npm config set legacy-peer-deps=true. That didn’t seem ideal but I couldn’t find a specific description of how to actually resolve the dependency conflict. I tried uninstalling and reinstalling the relevant modules but that didn’t work.
Finally I did try enabling legacy peer deps and deleting my modules, then reinstalling. That also didn’t work and left me with this error when trying to run locally:
./node_modules/aws-amplify-react/lib-esm/Amplify-UI/Amplify-UI-Components-React.js
Attempted import error: 'a' is not exported from '#aws-amplify/ui' (imported as 'AmplifyUI').
I wasn’t able to resolve that either. So I deleted modules again, ran npm install again, and now I’m back to the original error.

I had the exact same problem, but using --legacy-peer-deps should work. You are probably however running it only locally, and not when the application is being built in Amplify.
Go to your application in AWS Amplify and select Build settings from the sidebar menu. Next just replace
preBuild:
commands:
- npm ci
With:
preBuild:
commands:
- npm ci --legacy-peer-deps
That did the trick for me at least, hope it helps!
Documentation: https://docs.aws.amazon.com/amplify/latest/userguide/build-settings.html

Related

I cannot run npm install - ERESOLVE could not resolve

I have recently just cloned my project on to a fresh computer from Github. I deleted my node modules and ran npm install and I was presented with:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: #react-native-firebase/auth#14.2.1
npm ERR! Found: #react-native-firebase/app#13.0.1
npm ERR! node_modules/#react-native-firebase/app
npm ERR! #react-native-firebase/app#"^13.0.1" from the root project
npm ERR! peer #react-native-firebase/app#"13.0.1" from #react-native-firebase/storage#13.0.1
npm ERR! node_modules/#react-native-firebase/storage
npm ERR! #react-native-firebase/storage#"^13.0.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer #react-native-firebase/app#"14.2.1" from #react-native-firebase/auth#14.2.1
npm ERR! node_modules/#react-native-firebase/auth
npm ERR! #react-native-firebase/auth#"^14.2.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: #react-native-firebase/app#14.2.1
npm ERR! node_modules/#react-native-firebase/app
npm ERR! peer #react-native-firebase/app#"14.2.1" from #react-native-firebase/auth#14.2.1
npm ERR! node_modules/#react-native-firebase/auth
npm ERR! #react-native-firebase/auth#"^14.2.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/jacksaunders/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/jacksaunders/.npm/_logs/2022-06-18T18_48_11_817Z-debug-0.log
I have tried downgrading the packages, but I don't think I'm doing it right because it is not working. I have tried npm audit fix but that didn't work for me either and I am presented with the same error as above.
If anyone can help me get back up and running that would be great!
Thank you!
This error could be a directory issue. When cloning projects, you may have put your project folder inside a new folder you created. For example, C:/Users/myApp/myApp
Double check that your terminal you are running commands from is in the correct directory. This is a simple mistake I have made many times, causing that exact error.
If that is not the case, then I would freshly reinstall Firebase on this project. Check the log and see if all of the errors are firebase related from your code sample. Completely uninstalling firebase after npm install and installing the package separately can fix the issue.

Error occured while creating a react app and unable to start the react app

I am newbie to react technology and I faced an error while creating a react app:
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: frontend#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 C:\Users\nahee\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\nahee\AppData\Local\npm-cache\_logs\2022-04-12T12_46_13_743Z-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
As a result I am unable to start the app
For this I used npm uninstall -g create-react-app and npm cache verify commands to clear the error even though I am unable to resolve it.
For creating a react app I used
npx create-react-app frontend
What is my issue?
I think there is an issue with react-testing-library. Based on the error message, it supports only React < 18 version. You can read it here.
For an alternative solutions, you can manually add those to your project like how they mentioned on the error log(which I did for myself)
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
Or you can check this too.
create-react-app dependency version issues with React 18

Issues setting up react using Create React App

I am a newbie trying to set up React for the first time. I have an error when I am trying to install it on my computer. I have created a folder in my Documents folder for all the projects I was planning on making, if that makes a difference too. I am not running this in root. Below are the errors I keep getting and I am not sure what they mean. I have googled and found a few forum posts, but none of their solutions work. I am hoping it is something small I have missed.
Installing template dependencies using npm...
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR!
While resolving: my-app#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 C:\Users\Luke\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\Luke\AppData\Local\npm-cache_logs\2022-04-12T04_55_21_058Z-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 PS C:\Users\Luke\Documents\React-Projects>

while trying to install react-bootstrap-table i am getting an error like this

PS C:\Users\ravur\demo-web-page> npm install react-bootstrap-table
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: demo-web-page#0.1.0
npm ERR! Found: react#17.0.2
npm ERR! node_modules/react
npm ERR! react#"^17.0.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^15.0.0 || ^16.0.0" from react-bootstrap-table#4.3.1
npm ERR! node_modules/react-bootstrap-table
npm ERR! react-bootstrap-table#"*" 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\ravur\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\ravur\AppData\Local\npm-cache_logs\2021-04-27T07_14_51_100Z-debug.log
That is caused by the React version you are using react#"^17.0.2", while the react-bootstrap-table library is based upon react#"^15.0.0 || ^16.0.0".
Since the difference in version is a major release, you could incur in problems hard to debug, since react could have implemented changes that could have broken the library functionality e.a. reason why npm throws you that error.
At this point, you could either set your project to use react 16 instead of 17 to make sure nothing breaks or you could otherwise keep your version as is and force the library installation as such: npm i react-bootstrap-table --legacy-peer-deps.
If you opt for the second alternative, you know you won't need to use --legacy-peer-deps for new installations as soon as the library maintainers will update the library to work off v.17.

Cannot run gatsby develop - There was a problem loading the local develop command

I am trying to run gatsby develop in order to start the development server but I am getting the following error:
There was a problem loading the local develop command. Gatsby may not be installed in your site's "node_modules" directory. Perhaps you need to run "npm install"? You might need to delete your "package-lock.json" as well.
This is the project that I am working on: https://github.com/andreiprv/andyprv-blog
Cloned from this repo: https://github.com/alxshelepenok/gatsby-starter-lumen
It is probably a dependency issue, but I don't have the know-how to figure out how to solve it. After I started the project with gatsby new etc, I've got the following errors:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: gatsby-starter-lumen#3.0.7
npm ERR! Found: react#17.0.1
npm ERR! node_modules/react
npm ERR! react#"^17.0.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^16.4.2" from gatsby#2.28.0
npm ERR! node_modules/gatsby
npm ERR! gatsby#"^2.27.4" from the root project
npm ERR! peer gatsby#"*" from #sentry/gatsby#5.28.0
npm ERR! node_modules/#sentry/gatsby
npm ERR! #sentry/gatsby#"^5.27.6" 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/andreismbp/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/andreismbp/.npm/_logs/2020-12-04T17_22_00_512Z-debug.log
error Command failed with exit code 1: npm install
Error: Command failed with exit code 1: npm install
- error.js:56 makeError
[lib]/[gatsby-cli]/[execa]/lib/error.js:56:11
- index.js:114 handlePromise
[lib]/[gatsby-cli]/[execa]/index.js:114:26
- task_queues:93 processTicksAndRejections
node:internal/process/task_queues:93:5
- init-starter.js:135 install
[lib]/[gatsby-cli]/lib/init-starter.js:135:7
- init-starter.js:202 clone
[lib]/[gatsby-cli]/lib/init-starter.js:202:3
- init-starter.js:343 initStarter
[lib]/[gatsby-cli]/lib/init-starter.js:343:5
- create-cli.js:449
[lib]/[gatsby-cli]/lib/create-cli.js:449:9
I tried to uninstall and install gatsby again using npm uninstall --save gatsby && npm install --save gatsby
but it failed with the following errors
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: gatsby-starter-lumen#3.0.7
npm ERR! Found: react#17.0.1
npm ERR! node_modules/react
npm ERR! react#"^17.0.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^16.4.2" from gatsby#2.28.0
npm ERR! node_modules/gatsby
npm ERR! peer gatsby#"*" from #sentry/gatsby#5.28.0
npm ERR! node_modules/#sentry/gatsby
npm ERR! #sentry/gatsby#"^5.27.6" 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/andreismbp/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/andreismbp/.npm/_logs/2020-12-04T17_51_08_843Z-debug.log
Thank you in advance!
Did the following, ran npm install --legacy-peer-deps
Then hit another error when running gatsby develop :
Node Sass does not yet support your current environment: OS X 64-bit with Unsupported runtime (88)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.14.1
error undefined failed
Fixed the above by downgrading node to v14.15.1. After that I needed to run npm rebuild node-sass
I've resolved this issue by running yarn install instead of npm install
Not sure if this may be related, I had a similar issue, but mine was caused by a mismatch dependency between my node version and the version some library was using, so after changing to another version it worked for me.
I noticed that there was an error by running npm install --loglevel verbose
see if you can get additional information.

Resources