I’m trying to install the module via composer, but the package is not found. How to resolve it?

I’m trying to install the module via composer, but the package is not found. How to resolve it?

Composer is the dependency manager that allows you easily download the required files on your server. The files are located on a remote server, or a repository, that you need to add to the list of “known” ones and authenticate to using the username and password. During the process of installation, the composer checks all the available repositories and finds the package with the specified name. In case the package doesn’t belong to any of the known repositories or there is no such a package in the known repositories, composer can throw the following error:

[InvalidArgumentException] Could not find a matching version of package amasty/color-swatches-pro. Check the package spelling, your version constraint and that the package is available in a stability which matches your minimum-stability (alpha)

To resolve this issue, follow these steps:

1. Make sure you're using the correct composer name when downloading the package. The composer name of the purchased extension can be found in your Amasty.com account in Products tab:


2. If you're trying to retrieve a specific version, make sure this version is valid. The latest version of the main package is listed in the Version column:


3. Check if the Amasty repository is added to your instance. For that, navigate your Magento directory and open the composer.json file. The Amasty repository should be listed under repositories section:


If the Amasty repository is missing, run the below command to add it:

composer config repositories.amasty composer <path>

Where <path> indicates the repository for a specific Magento edition:
  1. https://composer.amasty.com/community/ - for Community extensions.
  2. https://composer.amasty.com/enterprise/ - for Enterprise extensions.
4.  Make sure the module you're trying to download is available for you. To verify, you can run the following command:

composer show -a amasty/*

It will show all modules available in the Amasty repository for your composer keys. If the repository has been added correctly, the extension you try to retrieve will be displayed in the list: 


5. Make sure that you’re requesting the module using the composer keys from the same account that was used for the purchase. The username and password that you use for the authentication to composer repository should coincide with the public and private keys in your Amasty.com account.

To check the pair of keys you're currently using in your Magento, find the
auth.json file on your server. The path may differ from server to server, but generally, it is located in the home directory: ~/.composer/auth.json or in your Magento folder. The content of the file should contain composer keys for Amasty repository:


To make sure the keys match the ones generated in your Amasty.com account, log in to the Amasty.com account where you made a purchase and check the generated keys in Products > Access Keys section. If they do not match those in auth.json file, replace the current keys with the ones from your account:


If there are no keys set in your auth.json file for the Amasty repository, you can add them manually by editing the file, or use this command in the root Magento folder:

composer config --auth http-basic.composer.amasty.com COMPOSER_AMASTY_USERNAME COMPOSER_AMASTY_PASSWORD

Where COMPOSER_AMASTY_USERNAME is the Public Key and COMPOSER_AMASTY_PASSWORD is the Private Key.

6. Verify that your composer keys are enabled in your Amasty.com account. The status of the keys is set in the Access Keys section in the Products tab:


7. Flush composer cache with the command below:

composer clearcache