Carsen Miller
Carsen Miller

Reputation: 51

Module not found: Can't resolve './aws-exports'

Trying to create a react-native app using expo and AWS Amplify. I just went through all of the basic initialization steps of getting the app hosted on Amplify's admin console and then getting a basic GraphQL schema set up, as per Amplify's Documentation. Upon trying to launch my app with expo start I get the following error in App.js:

Module not found: Can't resolve './aws-exports'
  16 | import Amplify, { API, graphqlOperation } from 'aws-amplify';
> 17 | import awsconfig from './aws-exports';
  18 | Amplify.configure(awsconfig);

Notably, if I comment out lines 16-18 and try running expo-start again, the app runs just fine (just without the AWS-backend being plugged in)

Anyways, when I first saw this, I went and reviewed the import statements and found that while there was a module for aws-amplify, there wasn't one that existed in my repository for aws-exports. So I tried a few commands to see if I could get it downloaded.

  1. npm install aws-amplify to try and get the node module installed again
  2. amplify init to re-initialize the backend
  3. Re-cloning the github repo and trying amplify pull to grab the existing backend I'd previously created and try it on a new instance of the application.

I haven't had much luck with any of these attempts so I'm hoping to find more help here! Thanks :)

Upvotes: 4

Views: 15990

Answers (3)

supinie
supinie

Reputation: 113

This is an issue with there not being properly integrated CI/CD between your front and back end. Here is the docs on how you can easily set this up.

Please don't remove aws-exports from your gitignore, it can contain secrets that should not be exposed

Upvotes: 5

Abhishek Paul
Abhishek Paul

Reputation: 49

Just remove aws-exports from .gitignore this solves my issue.

Upvotes: 0

Azher Aleem
Azher Aleem

Reputation: 786

Assuming that you have already run the command amplify init in the terminal to initialize your amplify application and that your aws-exports file exists in the same directory as your app.js is?

If yes, then you need to understand that the aws-exports is an autogenerated file created when you initialize or pull the backend environment. The file by default exports an object named awsmobile. To make sure that it does, open the aws-exports file and check the name of the default export, copy that and replace the awsconfig in your import 'awsconfig' from './aws-exports'; statement.

Upvotes: 3

Related Questions