Composer throws [ReflectionException] Class Fxp\Composer\AssetPlugin\Repository\NpmRepository does not exist

后端 未结 7 484
-上瘾入骨i
-上瘾入骨i 2020-12-07 13:18

I installed the latest version (1.0.0. stable) of composer and in my Yii2 project I typed this:

php composer.phar update

It gives me this error

相关标签:
7条回答
  • 2020-12-07 13:43

    If none of the other solutions have worked for you, please try AssetPackagist as an alternative.

    1. Add the packages bower-asset/bootstrap and npm-asset/jquery to composer.json like the following:

      "require": {
          "bower-asset/bootstrap": "^3.3",
          "npm-asset/jquery": "^2.2"
      }
      
    2. Add a repositories block (if you still don't have one, if you do, just append to it) with the following content:

      "repositories": [
          {
              "type": "composer",
              "url": "https://asset-packagist.org"
          }
      ]
      
    3. Run composer install (or composer update)

    4. Considering that asset-packagist installs assets in a different directory, add the following lines to your application config (usually called as web.php):

      $config = [
          'aliases' => [
              '@bower' => '@vendor/bower-asset',
              '@npm'   => '@vendor/npm-asset',
          ],
      ];
      

    These instructions may change over time. They have been copied from the repo website so they could last in time just in case something happens to the website. I am not the author of the repo but I really appreciate the effort made into it. Please check https://asset-packagist.org/site/about to know more about the project.


    If you are struggling with composer, here you have some useful commands:

    composer clear-cache - Clear composer related caches

    composer install -vvv - Add the parameter "vvv" to show installation process related output (useful to debug)

    composer global show - Useful to check if you already have fxp/composer-asset-plugin installed. In my case, it already was, however it was not being detected as a dependency, and the solution I described earlier worked flawless to me - hope it does work for you too!

    0 讨论(0)
提交回复
热议问题