composer 安裝yiisoft/yii2出現一堆錯誤:如下
yiisoft/yii2 2.0.13.2 requires
bower-asset/jquery 3.2.*@stable | 3.1.*@stable | 2.2.*@stable
| 2.1.*@stable | 1.11.*@stable | 1.12.*@stable ->
no matching package found
這種錯誤可以使用如下命令解決:
composer global require “fxp/composer-asset-plugin:^1.2.0”
有些時候還要在composer.json中加入
"extra": {
"asset-installer-paths": {
"npm-asset-library": "vendor/npm",
"bower-asset-library": "vendor/bower"
}
}
然後有可能還會出現警告:
The "extra.asset-installer-paths" option is deprecated,
use the "config.fxp-asset.installer-paths" option
此時就按照提示的將在extra的改在config中就行,如下
"config" : {
"fxp-asset.installer-paths" : {
"npm-asset-library" : "vendor/npm",
"bower-asset-library" : "vendor/bower"
}
}
還有一件事!可能提示你沒存github token,提示
GitHub API limit (60 calls/hr) is exhausted,
could not fetch https://api.github.com/repos/jquery/jquery-dist.
Create a GitHub OAuth token to go over the API rate limit.
這個可以忽略,但是你會發現可能需要安裝的特別多,所以,還是直接設置一個吧
到github上 https://github.com/settings/tokens/new 登錄賬號,選擇需要的權限,點擊生成token即可
這裏還可能出現vendor/bower/jquery/dist文件不存在
在vendor目錄中存在bower-asset目錄而不存在bower目錄
- 可以修改 入口文件加上配置
"aliases" => [
"@bower" => "@vendor/bower-asset",
"@npm" => "@vendor/npm-asset"
]
- 另外一種就是直接運行
composer install -vvv