Rohit Upadhyay
Rohit Upadhyay

Reputation: 76

Module not found: Can't resolve '@aws-amplify/core'

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

Answers (4)

Umesh Naik
Umesh Naik

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.

  1. Removed node_modules and package-lock.json files.
  2. npm install

Upvotes: 2

AllisLove
AllisLove

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

Priyam Ghosh
Priyam Ghosh

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

edgc
edgc

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

Related Questions