始めて一週間なのであまり信用しないでください. 自分用メモです.
Don't trust information on this page cause I'm new.
Error: TypeError: Cannot read property 'idToken' of undefined
amplify init で発生
E:\AWS-Amplify\desktopapp3>amplify init --appId hogehoge
Note: It is recommended to run this command from the root of your app directory
? Enter a name for the project desktopapp3
? Enter a name for the environment staging
? 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.cmd run-script build
? Start Command: npm.cmd run-script start
Using default provider awscloudformation
For more information on AWS Profiles, see:
https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html
Failed to fetch Amplify Admin credentials
init failed
Error: TypeError: Cannot read property 'idToken' of undefined
at Object.getAwsConfig (C:\Users\hogehoge\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-provider-awscloudformation\src\configuration-manager.ts:)
at processTicksAndRejections (internal/process/task_queues.js:)
at Object.run (C:\Users\hogehoge\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-provider-awscloudformation\src\initializer.js:hogehoge)
initが失敗してしまう
検索すると以下のサイトがヒット
amplify env add: Cannot read property 'idToken' of undefined
バージョンが新しいとだめらしいので
removeして古いものをインストール
ちなみにWin Macどちらでもエラーが出た
npm remove -g @aws-amplify/cli
npm install -g @aws-amplify/cli@4.36.2
このあとamplify configureを行うことが大切
しかしamplify init -appIdをするとエラー
E:\AWS-Amplify\desktopapp3>amplify init --appId hogehoge
Note: It is recommended to run this command from the root of your app directory
? Enter a name for the project desktopapp3
? Enter a name for the environment dev
? 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.cmd run-script build
? Start Command: npm.cmd run-script start
Using default provider awscloudformation
init failed
InvalidSignatureException: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.
しかし環境の名前をstagingと
webの管理画面ときちんと一致させるとエラーが発生しなくなった
E:\AWS-Amplify\desktopapp3>amplify init
Note: It is recommended to run this command from the root of your app directory
? Enter a name for the project desktopapp3
? Enter a name for the environment staging
? 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.cmd run-script build
? Start Command: npm.cmd run-script start
Using default provider awscloudformation
Your project has been successfully initialized and connected to the cloud!
ここを変更
? Enter a name for the environment staging
? Enter a name for the environment dev
!!! Build failed
git push origin master をした後にAWS-Amplifyで自動でビルドする時に発生
細かく見ると原因は以下
Cannot find file './aws-exports' in './src'.
ローカルで確認するとaws-exports.jsはある
しかしgithubを見るとない
ここでgit addをすると
E:\AWS-Amplify\desktopapp3>git add src\aws-exports.js
The following paths are ignored by one of your .gitignore files:
src/aws-exports.js
hint: Use -f if you really want to add them.
hint: Turn this message off by running
hint: "git config advice.addIgnoredFile false"
なぜかgitignoreでgit addできなくなっている
そこで
#amplify
amplify/\#current-cloud-backend
amplify/.config/local-*
amplify/mock-data
amplify/backend/amplify-meta.json
amplify/backend/awscloudformation
build/
dist/
node_modules/
#aws-exports.js
awsconfiguration.json
amplifyconfiguration.json
amplify-build-config.json
amplify-gradle-config.json
amplifytools.xcconfig
コメント化して強制的にgit addさせる
User pool client hogehoge does not exist.
React アプリケーションの構築をもとにつくったアプリでアカウントを作ろうとしたらエラーが画面上部に出現
amplify pullでAmplify Adminにアカウントがわからずサインインできない
ユーザ名 aws-amplify-admin
パスワード 空白
でログインできる
Failed to communnicate with the Amplify CLI. You can try again by running:
amplify pullで自動的に立ち上がったAmplify Adminに
aws-amplify-adminでログインをしようとすると発生
このときのamplifyは
(base) hogehoge-MacBook-Pro:desktopapp3 hogehoge$ amplify -v
4.40.0
多分バージョンのせい
なのでアップデートしてみる
古いものに戻すのではなく
amplify upgrade
しかし治らないので
バージョンを4.36.2にした
実行環境
E:\AWS-Amplify\desktopapp3>amplify -v
4.36.2
E:\AWS-Amplify\desktopapp3>npm -v
6.14.9
E:\AWS-Amplify\desktopapp3>node -v
v14.15.3
参考文献
AWS公式 React アプリケーションの構築