Composer 2: InvalidArgumentException /vendor/bower-asset/jquery/dist

Error: Invalid Argument – [yii\base\InvalidArgumentException]

Environment:

  • Yii 2.0.40
  • PHP 7.4.9
  • Composer 2.0.8
  • MAMP

I try to:

  • Remove “fxp/composer-asset-plugin” and add repository section in composer.json :arrow_heading_up:
  • Add ‘aliases’ in config
  • Delete .lock, delete vendor directory, clean composer cache & composer install

In conclusion jquery (JqueryAsset) aren’t available in “vendor/bower-asset/”

Any idea?

composer.json:

{
“name”: “yiisoft/yii2-app-advanced”,
“description”: “Yii 2 Advanced Application Template”,
“keywords”: [“yii2”, “framework”, “advanced”, “application template”],
“homepage”: “http://www.yiiframework.com/”,
“type”: “project”,
“license”: “BSD-3-Clause”,
“support”: {
},
“minimum-stability”: “stable”,
“require”: {
“php”: “>=5.4.0”,
“yiisoft/yii2”: “2.0.",
“yiisoft/yii2-bootstrap”: “~2.0.10”,
“yiisoft/yii2-swiftmailer”: "2.1.
”,
“yiisoft/yii2-imagine”: “2.2.",
“fortawesome/font-awesome”: “v4.3”,
“phpmailer/phpmailer”: “@stable”,
“zyx/zyx-phpmailer”: “@stable”,
“linslin/yii2-curl”: "1.4.
”,
“cinghie/yii2-cookie-consent”: “",
“bower-asset/jquery.lazyload”: “@stable”,
“bower-asset/bootstrap”: “^3.3”,
“bower-asset/fontawesome”: "4.2.
”,
“bower-asset/jquery.inputmask”: “3.1.",
“bower-asset/moment”: "2.8.
”,
“bower-asset/typeahead.js”: “0.10.5”,
“bower-asset/yii2-pjax”: “2.0.",
“bower-asset/cookieconsent”: "2.0.
”,
“bower-asset/jquery”: “^3.5”
},
“require-dev”: {
“yiisoft/yii2-debug”: “~2.1.0”,
“yiisoft/yii2-gii”: “~2.1.0”,
“yiisoft/yii2-faker”: “~2.0.0”,
“codeception/codeception”: “^4.0”,
“codeception/verify”: “~0.5.0 || ~1.1.0”,
“codeception/specify”: “~0.4.6”,
“symfony/browser-kit”: “>=2.7 <=4.2.4”,
“codeception/module-filesystem”: “^1.0.0”,
“codeception/module-yii2”: “^1.0.0”,
“codeception/module-asserts”: “^1.0.0”
},
“extra”: {
“yii\composer\Installer::postCreateProject”: {
“setPermission”: [
{
“runtime”: “0777”,
“web/assets”: “0777”,
“yii”: “0755”
}
]
},
“asset-installer-paths”: {
“npm-asset-library”: “vendor/npm”,
“bower-asset-library”: “vendor/bower”
}
},
“config”: {
“process-timeout”: 1800,
“fxp-asset”: {
“enabled”: false
},
“discard-changes”: true
},
“repositories”: [
{
“type”: “composer”,
“url”: “https://asset-packagist.org
}
]

}

This issue always pop-up and the solutions seems to change from each one.

A quick way to solve this is by adding the "yidas/yii2-bower-asset":"*", to your “required” array in composer.json.

There is also a solution changing the position of the array “asset-installer-paths”, which someone recommend to move it inside the “extra” array of composer.json, you can read the original script here: https://github.com/yiisoft/yii2/issues/10198#issuecomment-312615114

Bruno, thanks for your answer!

I install "yidas/yii2-bower-asset":"*":

jquery has been installed, but other required libraries (like fontawesome) are not installed.

I have asset-installer-paths array inside extra
Captura de pantalla 2020-12-30 a las 14.59.59

Similar problems already in another threads, see possible solution also e.g. here.