Reputation: 76
Trying to create a React App using amplify authentication, stuck with this error
Module not found: Can't resolve '@aws-amplify/core' in '..\node_modules@aws-amplify\api\lib-esm'
I have been referring to these two links:
What have I already tried:
Any help is appreciated :)
Upvotes: 2
Views: 11939
Reputation: 117
I was facing the same errors after upgrading @aws-amplify/ui-react
from 1.x to 4.x
I have tried the below steps and errors got resolved after that.
node_modules
and package-lock.json
files.npm install
Upvotes: 2
Reputation: 489
Do npm install aws-amplify@latest
sometimes this problem happens cuz the version i think.
After stop the project and run it again.
Upvotes: 0
Reputation: 61
The perfect solution is as mentioned above. I found this after a lot of research. Need to install @aws-amplify/core. But along with that in my react app, I have to install some more packages for cognito to work properly.
npm i @aws-amplify/core --save --legacy-peer-deps
npm i @aws-amplify/storage --save --legacy-peer-deps
npm i @aws-amplify/interactions --save --legacy-peer-deps
npm i @aws-amplify/auth --save --legacy-peer-deps
npm i @aws-amplify/api --save --legacy-peer-deps
npm i @aws-amplify/analytics --save --legacy-peer-deps
npm i @aws-amplify/xr --save --legacy-peer-deps
Upvotes: 3
Reputation: 31
I ran into this issue working with AWS Datastore which also depends on @amplify/core. Here's how I resolved it:
npm i @aws-amplify/core --save --legacy-peer-deps
React component:
import Amplify from "@aws-amplify/core
The legacy peer deps flag was required in my case as the install React version was greater than the version required for amplify/core. You may also need to amplify init
or amplify pull
first if you've not already done so.
Upvotes: 3