📝
Amplify CLI で発生する team-provider-info.json' does not exist の解決方法
結論
There is a file called local-env-info.json where the path to the project is configured. This is the file which needs to be updated when the path of the repo change. Now amplify push / publish works again
amplify/.config/local-env-info.json の projectPath に実際のディレクトリとは異なるパスが記載されていたことが原因でした。
再現手順
Cloud9 環境で事象を再現してみました。
# Amplify CLI のインストール
$ mkdir -p ~/.npm-global
$ npm config set prefix '~/.npm-global'
$ echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
$ source ~/.bashrc
$ npm install -g @aws-amplify/cli
$ amplify init
# アクセスキーやリージョンを設定
この時点で amplify/.config/local-env-info.json が作成されており、projectPath は存在するパスになっています。

エラーを再現するために projectPath を以下のように存在しないパスに変更します。
{
"projectPath": "/home/ec2-user/dummy",
"defaultEditor": "Visual Studio Code",
"envName": "dev"
}
この状態で amplify pull を実行するとタイトルのエラーが発生します。
$ amplify pull --appId d2fpbun0yaf4nh --envName dev
Pre-pull status:
Current Environment: dev
┌──────────┬───────────────┬───────────┬─────────────────┐
│ Category │ Resource name │ Operation │ Provider plugin │
└──────────┴───────────────┴───────────┴─────────────────┘
✖ There was an error initializing your environment.
🛑 File at path: '/home/ec2-user/dummy/amplify/team-provider-info.json' does not exist
Resolution: Please report this issue at https://github.com/aws-amplify/amplify-cli/issues and include the project identifier from: 'amplify diagnose --send-report'
Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/
Session Identifier: 86ca6ac1-51a2-44f5-a9a2-857179360f5c
projectPath を存在するパスに修正することで上記エラーが解消することも確認できました。
{
"projectPath": "/home/ec2-user/environment",
"defaultEditor": "Visual Studio Code",
"envName": "dev"
}
$ amplify pull --appId d2fpbun0yaf4nh --envName dev
Pre-pull status:
Current Environment: dev
┌──────────┬───────────────┬───────────┬─────────────────┐
│ Category │ Resource name │ Operation │ Provider plugin │
└──────────┴───────────────┴───────────┴─────────────────┘
✔ Successfully pulled backend environment dev from the cloud.
✅
Post-pull status:
Current Environment: dev
┌──────────┬───────────────┬───────────┬─────────────────┐
│ Category │ Resource name │ Operation │ Provider plugin │
└──────────┴───────────────┴───────────┴─────────────────┘
その他の原因
File at path: '/home/ec2-user/environment/amplify/team-provider-info.json' does not exist
エラーメッセージ通り、team-provider-info.json が存在しない場合にも同様のエラーが発生します。
また、team-provider-info.json が amplify ディレクトリの直下に存在しない場合にも同様のエラーが発生します。
まとめ
今回は Amplify CLI で発生する team-provider-info.json' does not exist の解決方法を紹介しました。
どなたかの参考になれば幸いです。
Discussion