错误解决: [InvalidArgumentException] Script "post-install-cmd" is not defined in this package

我使用 Laravel Installer 安装 Laravel 5.5 项目:

laravel new lara55

在安装的最后报了一个错:

> [@php](https://learnku.com/users/10050) -r "file_exists('.env') || copy('.env.example', '.env');"

  [InvalidArgumentException]
  Script "post-install-cmd" is not defined in this package

run-script [--timeout TIMEOUT] [--dev] [--no-dev] [-l|--list] [--] [<script>] [<args>]...

Application ready! Build something amazing.

就是 「[InvalidArgumentException] Script "post-install-cmd" is not defined in this package」,如果不注意,你几乎看不到。而且最后提示 「Application ready」,但这有问题——至少在使用 npm run dev / npm run production 编译前端脚本时会失败

解决方法是:升级 Laravel Installer 版本,我现在的版本是:

> laravel -V
Laravel Installer 1.3.6

咱升级一下:

> composer global update
Changed current directory to C:/Users/zhangb/AppData/Roaming/Composer
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 5 updates, 0 removals
  - Updating symfony/process (v3.3.2 => v3.3.9): Loading from cache
  - Installing symfony/filesystem (v3.3.9): Downloading (100%)
  - Updating symfony/polyfill-mbstring (v1.4.0 => v1.5.0): Downloading (100%)
  - Updating symfony/debug (v3.3.2 => v3.3.9): Loading from cache
  - Updating symfony/console (v3.3.2 => v3.3.9): Loading from cache
  - Updating laravel/installer (v1.3.6 => v1.4.1): Downloading (100%)
Writing lock file
Generating autoload files

下面再重新安装项目:

> laravel new lara55
> cd lara55
> php artisan -V
Laravel Framework 5.5.3

即可。这样的话,那么以后还是使用

composer create-project --prefer-dist laravel/laravel lara55 "5.5.*"

的方式更保险些。

参考连接:https://github.com/laravel/framework/issue...

本作品采用《CC 协议》,转载必须注明作者和本文链接
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!