Reputation: 443
I'm using react native for my project. On my old machine, when i ran amplify status, i had Auth
, Api
and Storage
services listed.
I moved to my new machine, installed node, watchman, brew etc... and then navigated to my react native project and ran: react-native run-ios
, and voila, my app is running. All the calls to my AWS Api, Auth and Storage are working perfectly.
Now i can make some amplify commands. Such as amplify status
. I tried: amplify env add
: here's what i got:
Users-MBP-2:projectname username$ amplify env add
Note: It is recommended to run this command from the root of your app directory
? Do you want to use an existing environment? Yes
? Choose the environment you would like to use: dev
Using default provider awscloudformation
✖ There was an error initializing your environment.
init failed
Error: ENOENT: no such file or directory, open '/Users/username/.aws/credentials'
at Object.openSync (fs.js:462:3)
at Proxy.readFileSync (fs.js:364:35)
at Object.readFileSync (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/util.js:95:26)
at IniLoader.parseFile (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/shared-ini/ini-loader.js:6:47)
at IniLoader.loadFrom (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/shared-ini/ini-loader.js:56:30)
at Config.region (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/node_loader.js:100:36)
at Config.set (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/config.js:507:39)
at Config.<anonymous> (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/config.js:342:12)
at Config.each (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/util.js:507:32)
at new Config (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/config.js:341:19) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/Users/username/.aws/credentials'
}
Do you think credentials info needs to be brought/configured to my new machine?
When i run amplify configure project
it's like doing an amplify init
and building a project from scratch. I'm being asked:
? Enter a name for the project: ProjectName
? Choose your default editor: Visual Studio Code
? Choose the type of app that you're building javascript
Please tell us about your project
? What javascript framework are you using (Use arrow keys)
angular
ember
ionic
react
❯ react-native
vue
none
etc....
I also already have a region, username and accessKey, secretAccess key etc..
I do not want to replace or ruin anything in my current backend or current project! Whats going on?
Upvotes: 1
Views: 11120
Reputation: 11
I tried every solution then I found this. (in MacBook)
% sudo -i
Password:
~ root# npm install -g @aws-amplify/cli
-- Ctrl+D to exist from Root user
% amplify pull --appId xxxx --envName yyyy.
Note: To get --appId xxxx --envName yyyy Log in to the AWS console. Choose AWS Amplify. Click your app. Go to Backend environments. Find the backend environment you wish to pull. Click Edit backend. See top right then click 'Local setup instructions ' ( amplify pull --appId YOUR_APP_ID --envName YOUR_ENV_NAME )
Waiting until it request to verify your amplify. ✔ Successfully received Amplify Studio tokens. ? Choose your default editor: Visual Studio Code ? Choose the type of app that you're building javascript Please tell us about your project ? What javascript framework are you using react ? Source Directory Path: src ? Distribution Directory Path: build ? Build Command: npm run-script build ? Start Command: npm run-script start ✔ Synced UI components. ? Do you plan on modifying this backend? Yes ⠴ Building resource api/xxxx✅ GraphQL schema compiled successfully.
Edit your schema at .... ✔ Successfully pulled backend environment yyyy from the cloud. ✅
Successfully pulled backend environment staging from the cloud. Run 'amplify pull' to sync future upstream changes.
% amplify pull
% npm install
% npm start
Hope this help every one!!
Happy Coding :)
Upvotes: 1
Reputation: 7730
npm install -g @aws-amplify/cli
amplify configure
Running amplify configure is mainly to give the cli knowledge of your AWS account so subsequent commands can have access to things.
If you get amplify: command not found
errors try restarting your terminal. If still no luck, you will need to check amplify has been added to your PATH variable.
amplify env add
, but choose an existing environment. This will let you choose the environment you created on your other machine so you can pull those settings down to your new machine. amplify env add
? Do you want to use an existing environment? Yes
Production
Follow up with:
amplify pull
You don't need to run amplify add auth
again or anything. All of that will pull down automatically after you've done the above.
Upvotes: 6
Reputation: 13
You DO NOT need to do all config again, but some for sure
You have to install amplify cli npm install -g @aws-amplify/cli
use amplify pull
https://docs.amplify.aws/cli/start#amplify-pull
Follow the rest of steps - -- provide the accessKeyId, secretAccessKey -- region -- select amplify project
and then rest of app related thing like IDE, directory......
Upvotes: 1