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"
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:
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.
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.
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.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With