Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Page updated Apr 30, 2024

Maintenance ModeYou are viewing Amplify Gen 1 documentation. Amplify Gen 1 has entered maintenance mode and will reach end of life on May 1, 2027. New project should use Amplify Gen 2. For existing Gen 1 projects, a migration guide and tooling are available to help you upgrade. Switch to the latest Gen 2 docs →

Amplify パッケージのアップグレード

Amplify パッケージをアップグレードする際、アップグレードの結果として node_modules フォルダツリーに Amplify パッケージの重複バージョンがないことを確認することが重要です。複数バージョンのパッケージがあると、コードでインポートされたモジュールが Amplify.configure を呼び出すときに Amplify で構成されていないバージョンを指す可能性があり、予期しない動作が発生する可能性があります。

パッケージの重複バージョンを示唆する可能性のあるシナリオとしては、以下のようなコンソールメッセージが表示されることが考えられます:

  • Amplify has not been configured correctly
  • Please make sure the Auth module is configured with a valid Cognito User Pool ID
  • User pool is not configured

この状況を防ぐために、重複バージョンの確認を行い、重複バージョンが存在する場合は、Amplify パッケージのアップグレードを行うことができます。

重複バージョンの確認

以下のコマンドは、node_modules フォルダに複数回現れる Amplify パッケージを表示します。出力が空の場合、Amplify パッケージの重複バージョンがないことを意味します。

# Using YARN
yarn list --pattern amplify | \
grep -o -e '@\?aws-amplify[^ ]*' | \
sort | uniq | \
sed -E 's/^(@?[^@]+).*$/\1/g' | \
uniq -d | sort
# Using npm
npm ls -all 2>/dev/null | \
grep -o -e '@\?aws-amplify[^ ]*' | \
sort | uniq | \
sed -E 's/^(@?[^@]+).*$/\1/g' | \
uniq -d | sort
# Using YARN
yarn list --pattern amplify |
Select-String -Pattern '(@?aws\-amplify[^@]*).*(?<!deduped)$' |
%{$_.Matches.Groups[1].value} | Group-Object |
Where-Object { $_.Count -gt 1 } | Select-Object -ExpandProperty Name |
Sort-Object
# Using npm
npm ls -all 2>$null |
Select-String -Pattern '(@?aws\-amplify[^@]*).*(?<!deduped)$' |
%{$_.Matches.Groups[1].value} | Group-Object |
Where-Object { $_.Count -gt 1 } | Select-Object -ExpandProperty Name |
Sort-Object