Page updated Mar 28, 2024

Upgrading Amplify packages

When upgrading Amplify packages, it is important to make sure that there are no duplicate versions of Amplify packages in the node_modules folder tree as a result of the upgrade. Having multiple versions of packages can yield unexpected behavior as modules imported in your code might point to versions not configured by Amplify when calling Amplify.configure.

A likely scenario that could point to duplicate versions of packages is getting console messages like:

  • 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

To prevent this situation, you can Check for duplicate versions, and if duplicate versions exists, then Upgrade Amplify packages.

Check for duplicate versions

The following commands will show you Amplify packages that appear multiple times in your node_modules folder. If the output is empty, it means that you don't have duplicate versions of Amplify packages.

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