skip to Main Content

I’m building a React Native App using Amplify. App works fine and I can run it locally using npx expo start.

I’m now trying to use eas build and for both iOS and Android builds (locally or in cloud), it fails with the following error:

Error: Unable to resolve module ../amplifyconfiguration.json from /home/expo/workingdir/build/frontend/app/_layout.tsx: 
None of these files exist:
  * amplifyconfiguration.json(.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.mjs|.native.mjs|.mjs|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.cjs|.native.cjs|.cjs|.android.scss|.native.scss|.scss|.android.sass|.native.sass|.sass|.android.css|.native.css|.css)
  * amplifyconfiguration.json/index(.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.mjs|.native.mjs|.mjs|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.cjs|.native.cjs|.cjs|.android.scss|.native.scss|.scss|.android.sass|.native.sass|.sass|.android.css|.native.css|.css)
  21 | // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  22 | // @ts-ignore - amplify config is git ignored, as it depends on the environment, should be generated when you pull
> 23 | import config from '../amplifyconfiguration.json';
     |                     ^
  24 | import { enGB, registerTranslation } from 'react-native-paper-dates';
  25 | import { fetchAuthSession } from 'aws-amplify/auth';

Is the only solution to somehow login to amplify in the EAS build process and pull the desired environment or have I done something wrong?

2

Answers


  1. In your .gitignore file, you might have amplifyconfiguration.json. Just comment out this file and your build will execute just fine.

    Login or Signup to reply.
  2. The amplifyconfiguration.json file is usually created by the AWS Amplify CLI when you set up your Amplify project. It contains specific configuration details for different environments, such as API endpoints, authentication settings, and other resources in your AWS backend.

    If you’re experiencing errors related to amplifyconfiguration.json not being found or resolved during your build process, make sure to:

    1. Check File Existence: Verify that amplifyconfiguration.json exists in your project directory.

    2. Version Control: Ensure that the file is being tracked by version control (Git) and isn’t gitignored, if it’s necessary for your build process.

    3. Amplify Setup: Double-check that your AWS Amplify project is properly configured and synced (run amplify pull if needed) to generate the amplifyconfiguration.json file.

    Including amplifyconfiguration.json is essential for your app to correctly interact with AWS services configured through Amplify, both during development and in production builds.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search