Issues with Composer at module dependencies The Currency module requires Composer dependencies. I am trying to install it with the following command:

composer.phar require drupal/currency


It returns the following error.


  [InvalidArgumentException]
  Could not find package drupal/currency at any version for your minimum-stability (stable). Check the package spelling or your minimum-stability 


What am I doing wrong?

Furthermore, if I specify the version of currency with composer.phar require drupal/currency:8.x-3.1, I get this error:


  [UnexpectedValueException]
  Could not parse version constraint 8.x-3.1: Invalid version string "8.x-3.1"


Anything is going wrong and I don't know what. The file composer.json and composer.phar are both in root directory of the Drupal installation.
The error message could make you think there isn't any stable release of the module, but since there is a 8.x-3.1 version, that is not the case.

The possible causes are:


composer.phar require drupal/currency is not executed from the directory containing the composer.json file you are using, or the one Drupal comes with
The composer.json file doesn't list as repository the one having drupal/currency as package
The repository listed from the composer.json file as the one containing the drupal/currency package is the wrong one
The composer.json file is referring, in the repositories section, a server that is not anymore active, or where the packagist service has been disabled


Keep in mind that Composer, by default, looks at the packages in https://packagist.org. That is why the composer.json file that comes with Drupal 8.4 contains the following lines.

"repositories": [
    {
        "type": "composer",
        "url": "https://packages.drupal.org/8"
    }
]


If you were using https://packages.drupal.org/7 for Drupal 8, you would get the wrong modules. If you are using https://packagist.drupal-composer.org, that repository is not anymore working.

Keep also in mind that, if you were previously using https://packagist.drupal-composer.org, and you passed to https://packages.drupal.org/8, the package versions need to be accordingly changed; for example, using https://packages.drupal.org/8, composer require honeypot:1.27 is requiring version 8.x-1.27 of the Honeypot module.