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

Viewed 15463

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"
3 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

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

Confing your projects, using terminal go to the main folder and amplify init to config your project

amplify init

Do you to use an existing environment? (Y/n) Y

Choose the environment you would like to use: dev

Choose your default editor: Visual Studio Code

Choose the type of app you're building: javascript

What javascript framework you're using: ionic

Source Directory Path: src

Distribution Directory Path: www

Build Command: npm run-script build

Do you want to use an AWS profile? Y

Please choose the profile you want to use: select your personal IAM profile
Related