The EAS build is unable to locate the aws-exports file

Currently, I am working on an Expo project integrated with AWS Amplify. To deploy on mobile, I utilize EAS from Expo. However, I frequently encounter this error message:

❌ Metro encountered an error:
Unable to resolve module ./src/aws-exports from /Users/expo/workingdir/build/App.tsx:

None of these files exist:
  * src/aws-exports(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)
  * src/aws-exports/index(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)
  11 | import Amplify from 'aws-amplify';
> 12 | import awsconfig from './src/aws-exports';
  15 | Amplify.configure(awsconfig);

Even though I have the aws-exports file and can run it locally without any issues, sometimes building the project results in this error. I haven't been able to identify a pattern as to when it occurs or not.

I suspect that it might be related to my .gitignore file (I believe EAS may check it before uploading to the server). I have already tried running the command with --clear-cache, but it hasn't had any noticeable effect.

Do you have any suggestions for what steps I can take next? :)

Answer №1

Instead of constantly updating the aws-exports.js file when using the base64 route, consider creating a .easignore file and transferring the contents from .gitignore to exclude the aws-exports.js file.

EAS will prioritize the .easignore over the .gitignore, making it easier for you as you won't have to make any more updates in the future.

Answer №2

The EAS build process has direct access to the current version of your code stored on Git. The most effective approach would be:

  • Encode the aws-exports.js file into base64 format
  • Add the encoded value as an EXPO secret environment variable
  • Decode that environment variable back into aws-exports.js during the pre-installation phase using the
    "eas-build-pre-install"
    npm script. For example:
"scripts":{
  "eas-build-pre-install": "echo $AWS_EXPORTS | base64 -d > ./src/aws-exports.js",
  ...
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Loading preferred routes in Angular 6+ Universal for faster performance

In my Angular 7 application, I have Angular Universal set up with Express and I am also utilizing Angular Routing. My goal is to have only the pre-login routes (marketing views) rendered server-side, while post-login routes are loaded using traditional cli ...

What is the method for importing a JavaScript file into my TypeScript file?

Recently, I've encountered an issue while working with Typescript and angular 2. I have built an EncryptionService that looks like this: import {Injectable} from 'angular2/core'; import './lib/hmac256-enc64'; @Injectable() ...

What is the reason that TypeScript cannot replace a method of the base class with a subtype?

Here's a straightforward example. type Callback<T> = (sender: T) => void; class Warehouse<T> { private callbacks: Callback<T>[]; public constructor(callbacks: Callback<T>[]) { this.callbacks = callbacks; ...

The TS type guard fails to identify a non-empty property in a class object

Encountering an issue with TypeScript that involves a class property typed as AmplitudeFeatureFlags | {} = {}; initialized as an empty object. Attempting to retrieve a value from this class property using a method that takes in a property name argument of ...

Limiting the parameter type in Node.js and TypeScript functions

Currently working on a Node.js project utilizing TypeScript. I'm attempting to limit the argument type of a function to a specific base class. As a newcomer to both Node and TypeScript with a background in C#, I may not fully grasp some of the langua ...

Is there a method to incorporate absolute paths in SCSS while working with Vite?

Currently, I am experimenting with React + Vite as webpack seems to be sluggish for me. My goal is to create a project starter, but I am facing difficulties in getting SCSS files to use absolute paths. Despite including vite-tsconfig-paths in my vite.confi ...

Why am I having trouble iterating through my array object?

Trying to showcase the contents of object within an array. However, unable to showcase any results. Why is this happening? This is what I've attempted so far: Demo available here: https://stackblitz.com/edit/ionic-dsdjvp?file=pages%2Fhome%2Fhome.ts ...

Tips on programmatically filtering angular lists

Is there a way to programmatically filter an Angular list? I'm currently working on a project where I need to filter subcategories by clicking on categories. For example, when clicking on "Drinks," I want to display items like Coke, Fanta, Pepsi... ...

What type of module from commonjs is typically brought into a typescript document?

When importing a CommonJS module in a Typescript source, an object containing exported features of the module is received. In a specific use case, the declarations for NodeJS's fs module declare the exports as (typescript-) module, not as type. An in ...

Troubleshooting the "TypeError: Swiper.initialize is not a function" Issue in React Swiper using TypeScript

Struggling to implement Swiper in a project using nextJs and Typescript. Attempting to modify styles with injectStyle but encountering an error during initialization without knowing how to resolve it. import { useRef, useEffect } from "react"; im ...

A guide on successfully sending parameters to Angular routes

Currently, I am delving into Angular and exploring various basic concepts such as routing, Observables (and subscribing to them), making HTTP requests, and utilizing routing parameters. One scenario I have set up involves sending a HTTP GET request to JSON ...

Tips for making use of incomplete types

Is there a way to reference a type in TypeScript without including all of its required fields, without creating a new interface or making all fields optional? Consider the following scenario: interface Test { one: string; two: string; } _.findWhe ...

Testing Angular applications using Karma

After utilizing the yo angular 1 generator, it generated a landing page and some tests. However, I am facing an issue when trying to compile the code in VS as I receive an error stating that "module('fountainFooter');" is undefined. /// <refe ...

Navigating a page without embedding the URL in react-router-dom

In my application, I am utilizing react-router-dom v5 for routing purposes. Occasionally, I come across routes similar to the following: checkup/step-1/:id checkup/step-2/:id checkup/step-3/:id For instance, when I find myself at checkup/step-1/:id, I int ...

Discovering child elements within an iframe using Angular and customizing their appearance

Is there a simple and effective way to locate child nodes within an iframe using Angular in order to access the HTML element? Currently, I have implemented the following method: I designated a reference variable within my iframe (#privacyPolicy) <ifra ...

Translating Python's slicing assignment syntax to JavaScript/TypeScript: A guide

Currently, I am in the process of converting a Python library into TypeScript. One specific challenge I am facing is translating this line of code from this particular repository: is_prime[start - segment_min::pk] = repeat(False, len(range(start - segment ...

Issue - Attempting to add an expectation result prior to the start of a test specification

Seeking assistance to comprehend why I am facing this problem while executing protractor e2e test in a jenkins job, but everything works fine when I run it locally. https://i.sstatic.net/TusZl.png Appreciate any help in advance. ...

Model experiencing issues with properly binding Angular data

I am currently struggling with getting data to bind correctly from my web service call to my angular model. In a simple example that I have created to demonstrate the issue, the <li></li> elements are being rendered on the page but they are all ...

Is there a collation method for MatSort that accommodates languages with alphabetical orders differing from Unicode orders?

When it comes to the Norwegian and Danish Alphabets, the proper order of the characters is as follows: Æ Ø Å However, MatSort follows the Unicode order for these characters: Å (197) Æ (198) Ø (216) Is there a way to implement collation to addre ...

Issue accessing member value in inherited class constructor in Typescript

My situation involves a class named A, with another class named B that is inherited from it. class A { constructor(){ this.init(); } init(){} } class B extends A { private myMember = {value:1}; constructor(){ super(); ...