Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to resolve "./aws-exports" from "App.js"

I have been building an app with awsamplify for quite some time now. Today I descided to run some test and when I did

npm run start-web

Everythin worked fine. Now I went on to run mobile test with the use of Expo and ran

npm run ios & npm run android

which both returned the following errors.

Unable to resolve "./aws-exports" from "App.js"

Building JavaScript bundle: error

my problem is similar to the one below just its amplify and not awsmobile

https://github.com/aws-amplify/amplify-js/issues/669

Deos anyone know what I can do to resolve this?

Thanks alot!

I jsut removed some unused imports and the error changed to this

Unable to resolve "@aws-amplify/ui/dist/style.css" from "node_modules\aws-amplify-react\dist\Amplify-UI\Amplify-UI-Components-React.js"
like image 246
jibidijib Avatar asked Jun 25 '19 22:06

jibidijib


People also ask

How do I install AWS exports on AWS mobile hub?

aws s3 cp s3://bucket/aws-exports.js ./src/aws-exports.js Sign in to the AWS Mobile Hub console. Choose your project. Choose Hosting and Streaming. Click Download aws-exports.js file. You can (and should) do this before every build. I have included the following in my package.json:

How to enable JavaScript in AWS-exports?

The solution is to create an ./src/@types/aws/aws-exports.d.ts TypeScript module declaration file. Also, since aws-exports.js is a .js file extension, tsconfig.json needs to be updated to allow JavaScript files.

How do I configure the AWS SDK for react apps?

aws-config.js is used by browser sessions to configure the SDK. aws-exports.js is used by SPA applications that are packed (by Webpack, Browserify, or similar tools) to configure the SDK. You need the aws-exports.js file for the React app. You can download this file from the Amazon S3 bucket using either the AWS Mobile Hub console or the AWS CLI.

How to integrate react app with AWS-exports?

You need the aws-exports.js file for the React app. You can download this file from the Amazon S3 bucket using either the AWS Mobile Hub console or the AWS CLI. To download via the CLI, use the following: aws s3 cp s3://bucket/aws-exports.js ./src/aws-exports.js Sign in to the AWS Mobile Hub console. Choose your project.


Video Answer


2 Answers

Barely mentioned in the AWS docs:

  • For setting up a local dev folder, from an existing amplify repo, use an amplify env pull,

    It will "pull" the ./aws-exports.js from the server, the latest one that was pushed there, similar to git push and git pull but for the amplify env

  • It's true that an amplify push will create the ./aws-exports.js file, but it will also "push" it to the server, overwriting whatever is there.

  • amplify status is also a handy command, similar to git status

like image 75
Mike Avatar answered Oct 07 '22 09:10

Mike


I ran amplify env pull and then found it in the ./src/aws-exports.js

not sure if the pull did it, or if it was always there but this is for an existing expo project

like image 32
Kendall Cable Avatar answered Oct 07 '22 09:10

Kendall Cable