AWS Amplify & React – Module not found: Can’t resolve ‘@aws-amplify/analytics’


I am trying to add Login functionality to a React app I’m building using Amplify and AWS Cognito, but when I add the following line in my Login.js file:

and try to compile, I get the following error:

I tried installing Amplify with homebrew and npm, but I can’t get around this, any tips?


Initially I had:

But The compiler couldn’t resolve aws-amplify, and I could only find aws-amplify-react in the node_modules folder so I changed it.

However, in “node_modules/aws-amplify-react/lib-esm/Analytics/trackLifecycle.js” in line 39:

The problem is that it can’t find aws-amplify… Did I make a mess while installing maybe?


I get a similar error

Failed to compile.

Module not found: Can’t resolve ‘@aws-amplify/analytics’ in ‘/Users/myuser/myproject/node_modules/aws-amplify-react/lib-esm/Analytics’

when following the Amplify tutorial.

The workaround I found is to execute:

npm i -S @aws-amplify/analytics @aws-amplify/interactions @aws-amplify/storage @aws-amplify/ui @aws-amplify/xr aws-amplify

Obviously, I would love to know how to avoid all these extra libraries.

Leave a Reply