Composer throws [ReflectionException] 类 Fxp\Composer\AssetPlugin\Repository\NpmRepository 不存在

2022-08-30 08:19:23

我安装了最新版本(1.0.0.稳定版)的作曲家,在我的Yii2项目中,我键入了这个:

php composer.phar update

它给了我这个错误:

[反射异常]类 Fxp\Composer\AssetPlugin\Repository\Npm存储库不存在

[错误异常]Fxp\Composer\AssetPlugin\Repository\AbstractAssetsRepository::whatProsites() 的声明应与 Composer\Repository\ComposerRepository::whatProvides(Composer\DependencyResolver\Pool $pool, $name, $bypassFilters = false) 兼容

有人可以帮我解决这个问题吗?

这是我的 composer.json

{
    "name": "yiisoft/yii2-app-advanced",
    "description": "Yii 2 Advanced Project Template",
    "keywords": ["yii2", "framework", "advanced", "project template"],
    "homepage": "http://www.yiiframework.com/",
    "type": "project",
    "license": "BSD-3-Clause",
    "support": {
        "issues": "https://github.com/yiisoft/yii2/issues?state=open",
        "forum": "http://www.yiiframework.com/forum/",
        "wiki": "http://www.yiiframework.com/wiki/",
        "irc": "irc://irc.freenode.net/yii",
        "source": "https://github.com/yiisoft/yii2"
    },
    "minimum-stability": "stable",
    "require": {
        "php": ">=5.4.0",
        "yiisoft/yii2": ">=2.0.6",
        "yiisoft/yii2-bootstrap": "*",
        "yiisoft/yii2-swiftmailer": "*",
        "kartik-v/yii2-widget-fileinput": "@dev",
        "golonka/bbcodeparser": "^2.2"
    },
    "require-dev": {
        "yiisoft/yii2-codeception": "*",
        "yiisoft/yii2-debug": "*",
        "yiisoft/yii2-gii": "*",
        "yiisoft/yii2-faker": "*"
    },
    "config": {
        "process-timeout": 1800
    },
    "extra": {
        "asset-installer-paths": {
            "npm-asset-library": "vendor/npm",
            "bower-asset-library": "vendor/bower"
        }
    }
}

答案 1

大约九天前(大约2016年3月底),api发生了变化。(#2668)因此,如果您已全局安装,则应对其进行更新。您可以使用以下命令执行此操作:Composer\Repository\ComposerRepository::whatProvidesfxp/composer-asset-plugin

php composer.phar global update fxp/composer-asset-plugin --no-plugins

答案 2

如果更新不起作用,请尝试使用此方法。

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

推荐