Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

Import {Auth} from "aws-amplify-react";

and try to compile, I get the following error:

Failed to compile.

./node_modules/aws-amplify-react/lib-esm/Analytics/trackLifecycle.js
Module not found: Can't resolve '@aws-amplify/analytics' in 'my_react_path/node_modules/aws-amplify-react/lib-esm/Analytics'

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

EDIT:

Initially I had:

Import {Auth} from "aws-amplify";

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:

import Analytics from '@aws-amplify/analytics';

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

like image 968
Danf Avatar asked Nov 12 '19 12:11

Danf


People also ask

What is the AWS amplify?

AWS Amplify is a set of purpose-built tools and features that lets frontend web and mobile developers quickly and easily build full-stack applications on AWS, with the flexibility to leverage the breadth of AWS services as your use cases evolve.

Is AWS amplify worth it?

I like to think of AWS Amplify as a kind of glue service. It really doesn't offer any particular core functionality besides helping you integrate with other AWS services, albeit it does it in a very different way. In essence, AWS Amplify is a toolchain that helps you build and deploy entire applications very quickly.

What is the difference between AWS Lambda and AWS amplify?

AWS Amplify is primarily designed to create and handle the backend of a web or mobile deployment using AWS, while Lambda provides the serverless cloud computing platform that executes codes in response to a pre-defined event.

What is amplify framework?

The Amplify Framework is a comprehensive set of SDKs, libraries, tools, and documentation for client app development. Amplify provides a continuous delivery and hosting service for web applications.


1 Answers

I get a similar error

Failed to compile.

./node_modules/aws-amplify-react/lib-esm/Analytics/trackLifecycle.js 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.

like image 79
cyrf Avatar answered Oct 10 '22 17:10

cyrf