错误解决: [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.*"
的方式更保险些。
本作品采用《CC 协议》,转载必须注明作者和本文链接