Trouble adding modules with Composer I created a Drupal 8 site through the manual install process and configured the site through the admin UI for a while. However, I quickly discovered how critical it was to use Composer to add modules due to the prevalence of third-party libraries. But I am getting the following error whenever I try to add any new module, and I will use Drupal Commerce module as an example (note that my production site is currently housed in the /public_html/main directory):

username@mydomain.com [~/public_html/main]# php 
/home3/username/public_html/composer require drupal/commerce
Using version ^2.7 for drupal/commerce
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 14 installs, 1 update, 0 removals
 - Installing drupal/coder (8.2.12): Cloning 984c54a7b1 from cache


[RuntimeException]                                                           
Failed to execute git clone --no-checkout 
'/home3/username/.composer/cache/  
vcs/https---git.drupal.org-project-coder.git/' 
'/home3/username/public_html  
/main/vendor/drupal/coder' --dissociate --reference 
'/home3/username/.compo  
ser/cache/vcs/https---git.drupal.org-project-coder.git/' &amp;&amp; cd 
'/home3/username/public_html/main/vendor/drupal/coder' &amp;&amp; git remote 
set-url origin 
'https://git.drupal.org/project/coder.git' &amp;&amp; git remote add composer 
'https://git.drupal.org/project/coder.git'                                           

Cloning into '/home3/username/public_html/main/vendor/drupal/coder'...       
done.                                                                        
fatal: unable to create thread: Resource temporarily unavailable             
fatal: cannot repack to clean up                                             


require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [-- 
no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update- 
with-dependencies] [--update-with-all-dependencies] [--ignore-platform- 
reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|-- 
optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] 
[--] [&lt;packages&gt;]...


Thanks for any help.
I have successfully battled this error into submission over the past six hours.
I pieced together what I believe were the contributing problems and found a way for things to work correctly in a remote hosted (Bluehost) Drupal installation.  


You must be able to use composer commands.  If composer is not installed on your remote host, you will need to install ssh and then install composer.  SSH lets you use command line typing so you can interact/execute composer commands
login to composer (I opened up Windows powershell and used SSH from there).  You will be challenged to put in your password for ssh the first time you use it.  If you have it configured tightly, you will be asked everytime.
cd www/your-drupal-directory If you don't start off in the drupal directory, you will not get code dropped into modules/contrib which means nothing will show up in your administration 'install' link from your site. Specifically, you login into composer and then just type the command and hit enter.  You'll then see your composer line now has your drupal path showing.  My path was www/d8 because Bluehost serves pages from www and I installed drupal in the d8 subdirectory. I'm sure public_html would have worked as well.
Commerce requires more than one module to run properly.  When you visit the Commerce installation page, pay careful attention to the Ludwig installation information.  The list of seven dependent modules is there.  You will need to be sure each dependent module is installed (some may already be installed).
--update-no-dev is the key to success.  Adding this option on your composer command will stop the addition of development packages during your module install.  A composer command for the general commerce package would be composer require drupal/commerce --update-no-dev then hit enter
Your next problem will be inconsistent 'stability' releases.  I used the default settings when I installed composer.  You can get around that problem by explicitly referencing the module version you want to install.  For example, Commerce requires the Entity module.  I used composer require drupal/entity:1.0-beta4 --update-no-dev


The issue of coder not being found seems to come from a difference between what is found in the composer.json file and the composer.lock file.  The update-no-dev is telling composer not to require the drupal/coder (and other things) 

I am no expert on composer or drupal development.  I'm sure others can provide a more technical explanation.  It is always a good idea to check for updates periodically for all installed modules and themes.  You should have a report in your administration link on your site that gives you an idea of available updates.