使用 Composer 从 Yii 2.0.x 升级时,报错:[ErrorException] Undefined variable: nameMatchesRequiredPackage 的分析解决

1、使用 Composer 从 Yii 2.0.x 升级时,报错: [ErrorException] Undefined variable: nameMatchesRequiredPackage,如图1

使用 Composer 从 Yii 2.0.x 升级时,报错: [ErrorException] Undefined variable: nameMatchesRequiredPackage

图1

PS E:/wwwroot/github-shuijingwan-yii2-app-advanced> composer update yiisoft/yii2 yiisoft/yii2-composer bower-asset/jquer
y.inputmask


  [ErrorException]
  Undefined variable: nameMatchesRequiredPackage


update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-custom-installers] [--no-autoload
er] [--no-scripts] [--no-progress] [--no-suggest] [--with-dependencies] [--with-all-dependencies] [-v|vv|vvv|--verbose]
[-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--prefer-stable]
[--prefer-lowest] [-i|--interactive] [--root-reqs] [--] [<packages>]...

2、更新 3 个包,先更新前 2 个,未报错,再更新第 3 个,报错,在当前项目搜索依赖包 bower-asset/jquery.inputmask,不存在,如图2

更新 3 个包,先更新前 2 个,未报错,再更新第 3 个,报错,在当前项目搜索依赖包 bower-asset/jquery.inputmask,不存在

图2

PS E:/wwwroot/github-shuijingwan-yii2-app-advanced> composer update yiisoft/yii2 yiisoft/yii2-composer
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
PS E:/wwwroot/github-shuijingwan-yii2-app-advanced> composer update bower-asset/jquery.inputmask


  [ErrorException]
  Undefined variable: nameMatchesRequiredPackage


update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-custom-installers] [--no-autoload
er] [--no-scripts] [--no-progress] [--no-suggest] [--with-dependencies] [--with-all-dependencies] [-v|vv|vvv|--verbose]
[-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--prefer-stable]
[--prefer-lowest] [-i|--interactive] [--root-reqs] [--] [<packages>]...
PS E:/wwwroot/github-shuijingwan-yii2-app-advanced> composer search bower-asset/jquery.inputmask
bower-asset/jquery.inputmask
PS E:/wwwroot/github-shuijingwan-yii2-app-advanced> composer search yiisoft/yii2-composer
yiisoft/yii2-composer The composer plugin for Yii extension installer
yiisoft/yii2-composer The composer plugin for Yii extension installer

3、查看 /vendor/yiisoft/yii2/composer.json 文件,bower-asset/jquery.inputmask 已经变更为 bower-asset/inputmask

    "require": {
        "php": ">=5.4.0",
        "ext-mbstring": "*",
        "ext-ctype": "*",
        "lib-pcre": "*",
        "yiisoft/yii2-composer": "~2.0.4",
        "ezyang/htmlpurifier": "~4.6",
        "cebe/markdown": "~1.0.0 | ~1.1.0",
        "bower-asset/jquery": "3.2.*@stable | 3.1.*@stable | 2.2.*@stable | 2.1.*@stable | 1.11.*@stable | 1.12.*@stable",
        "bower-asset/inputmask": "~3.2.2 | ~3.3.5",
        "bower-asset/punycode": "1.3.*",
        "bower-asset/yii2-pjax": "~2.0.1"
    },

4、在 Github 上查看此文件的提交日志,打开网址:https://github.com/yiisoft/yii2/commit/858e8015731da1af978af5e88eb495f3061fa120#diff-59858bca2a40c010f385eaa7b6f5137f ,如图3

在 Github 上查看此文件的提交日志

图3

5、使用 Composer 从 Yii 2.0.x 升级时,调整命令,bower-asset/jquery.inputmask 变更为 bower-asset/inputmask,更新成功,不再报错,如图4

使用 Composer 从 Yii 2.0.x 升级时,调整命令,bower-asset/jquery.inputmask 变更为 bower-asset/inputmask,更新成功,不再报错

图4

PS E:/wwwroot/github-shuijingwan-yii2-app-advanced> composer update yiisoft/yii2 yiisoft/yii2-composer bower-asset/input
mask
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/181305.html

(0)
上一篇 2021年10月31日
下一篇 2021年10月31日

相关推荐

发表回复

登录后才能评论