0

I can't get composer to work. It also fails when I try to deploy to Heroku.

$ composer update
  [ReflectionException]
  Class Fxp\Composer\AssetPlugin\Repository\NpmRepository does not exist

$ rm -r ~/.composer

$ composer global require fxp/composer-asset-plugin --no-plugins
Changed current directory to /home/Chloe/.composer
Using version ^1.1 for fxp/composer-asset-plugin
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing fxp/composer-asset-plugin (v1.1.4)
    Downloading: 100%

Writing lock file
Generating autoload files

$ composer update
  [ReflectionException]
  Class Fxp\Composer\AssetPlugin\Repository\NpmRepository does not exist

I tried the steps in Composer throws [ReflectionException] Class Fxp\Composer\AssetPlugin\Repository\NpmRepository does not exist and Updating composer throws exception Class Fxp\Composer\AssetPlugin\Repository\NpmRepository does not exist, but it still fails.

I also ran composer self-update and it still doesn't work.

PHP 5.6.19, Composer version 1.1-dev, Composer version 1.0.2 2016-04-21 12:30:18

Community
  • 1
  • 1
Chloe
  • 21,167
  • 37
  • 143
  • 289
  • just tried with that version of composer and the v1.1.4 of `composer-asset-plugin`, I've no problem. Can you share your composer.json? – Federkun Apr 24 '16 at 02:12
  • Here is the `composer.json`: http://pastie.org/private/4vvvpacgx5pzfrqd4kpg – Chloe Apr 24 '16 at 02:16
  • Some good hints from the Yii2 dev: http://stackoverflow.com/a/34939821/148844 – Chloe Apr 24 '16 at 05:03

2 Answers2

2

The problem is that you require a version of fxp/composer-asset-plugin that's now broken with composer >= 1.0.

"fxp/composer-asset-plugin": "^1.0",

Since you've installed it globally, you can remove it from your composer.json.

Federkun
  • 30,933
  • 8
  • 62
  • 80
  • I already tried deleting that line, but it still doesn't work. It still gives the same error message. – Chloe Apr 24 '16 at 02:20
  • `composer show -i`: `[ReflectionException] Class Fxp\Composer\AssetPlugin\Repository\NpmRepository does not exist`. Yes, I ran `composer update` after I deleted that line in `composer.json` and saved. – Chloe Apr 24 '16 at 02:25
  • 2
    please, delete `vendor` and `composer.lock`, then re-install with `composer install` and retry. Or do it with `composer update --no-plugin` – Federkun Apr 24 '16 at 02:26
  • OK I deleted `vendor/` and `composer.lock` and the version line, but it gave me an unrelated error: http://pastie.org/private/lythgvfk2it5nu3yo3ohw – Chloe Apr 24 '16 at 02:29
  • have you installed the plugin with `composer global require "fxp/composer-asset-plugin:~1.1"`? what's the output of `composer global show -i`? – Federkun Apr 24 '16 at 02:34
  • `composer global show -i` yields `Changed current directory to /home/Chloe/.composer You are using the deprecated option "installed". Only installed packages are shown by default now. The --all option can be used to show all packages. fxp/composer-asset-plugin v1.1.4 NPM/Bower Dependency Manager for Composer`. I finally fixed the unrelated error by running the 'global require' again and now `composer update works`. For some reason `composer` seems to suck. I wish it worked as good as `gem` for Ruby. – Chloe Apr 24 '16 at 04:59
  • You were using an old version of `fxp/composer-asset-plugin` locally, that's it. Now that composer is stable, no more BC like that would be introduce. – Federkun Apr 24 '16 at 09:58
2

I had a similar error. Try

composer global require fxp/composer-asset-plugin --no-plugins

this worked for me

natral
  • 775
  • 1
  • 12
  • 32