错误解决: [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 协议》,转载必须注明作者和本文链接
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

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