Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find file './aws-exports' in './src'

Tags:

aws-amplify

I'm on the third module of this AWS tutorial to build a React app with AWS, Amplify and GraphQL but the build keeps breaking. When I ran amplify push --y the CLI generated ./src/aws-exports.js and added the same file to the .gitignore. So I'm not surprised the build is failing, since that file isn't included when I push my changes.

So I'm not sure what to do here. Considering it's automatically added to the .gitignore I'm hesitant to remove it.

Any suggestions?

like image 360
Barryman9000 Avatar asked Jul 02 '20 23:07

Barryman9000


People also ask

What is the AWS exports js file?

aws-exports. This file is generated only for JavaScript projects. It contains the consolidated outputs from all the categories and is placed under the src directory specified during the init process. It is updated after amplify push . This file is consumed by the Amplify JavaScript library for configuration.

Could not find a declaration file for module AWS amplify react native?

The error "could not find declaration file for module 'react'" occurs when TypeScript cannot find the type declaration for a react-related module. To solve the error install the types for the module by running the command from the error message, e.g. npm install -D @types/react .

What does amplify pull do?

The amplify pull command pulls down the latest backend environment to your local development. It is used in two scenarios: On projects already initialized by the Amplify CLI, it pulls down the latest from the Cloud and updates the contents in the amplify/#current-cloud-backend directory.

How do I redeploy AWS amplify?

To manually deploy an app from Amazon S3 or a public URL Sign in to the AWS Management Console and open the Amplify console . At the top of the page, choose Get started. In the Deliver section, choose Get started. On the Host your web app page, choose Deploy without Git provider.


1 Answers

I'm assuming you are trying to build your app in a CI/CD environment? If that's the case then you need to build the backend part of your amplify app before you can build the frontend component.

For example, my app is building from the AWS amplify console and in my build settings I have

version: 0.1
backend:
  phases:
    build:
      commands:
        - '# Execute Amplify CLI with the helper script'
        - amplifyPush --simple
frontend:
  phases:
    preBuild:
      commands:
        - yarn install --frozen-lockfile
    build:
      commands:
        - yarn build
  artifacts:
    baseDirectory: build
    files:
      - "**/*"
  cache:
    paths:
      - node_modules/**/*

Note that the backend is building first with the amplifyPush --simple command. This is what generates the aws-exports.js file.

like image 88
Matthew Avatar answered Oct 20 '22 07:10

Matthew