laravel 错误:您引用了一个不存在的脚本@php artisan package:discover

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48760744/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 17:22:51  来源:igfitidea点击:

Error: You made a reference to a non-existent script @php artisan package:discover

phplaravelcomposer-php

提问by Waqas Bukhary

I am getting error at running composer dump-autoloadat laravel project

我在 laravel 项目中运行composer dump-autoload时出错

composer dump-autoload
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
You made a reference to a non-existent script @php artisan package:discover

Then executing php artisan package:discover returns

然后执行 php artisan package:discover 返回

Discovered Package: barryvdh/laravel-ide-helper
Discovered Package: cartalyst/sentinel
Discovered Package: laravelcollective/html
Discovered Package: laracasts/generators
Package manifest generated successfully.

Then again getting the same error

然后再次得到同样的错误

composer dump-autoload
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
You made a reference to a non-existent script @php artisan package:discover

What may be wrong? composer self-updateor composer global updatenot helping.

可能有什么问题?composer self-updatecomposer global update不帮助。

回答by Waqas Bukhary

Okay, I think that composer dump-autoloadis working even with that warning. (thanks to the user:Sohel0415comments) composer was not able to run script with @ symbol in composer.json file.

好的,我认为composer dump-autoload即使有那个警告也能奏效。(感谢用户:Sohel0415评论)composer 无法在 composer.json 文件中运行带有 @ 符号的脚本。

If you want to get rid of this warning simply do

如果您想摆脱此警告,只需执行

composer dump-autoload --no-scripts

composer dump-autoload --no-scripts

or

或者

you may delete the script with @ "post-autoload-dump": []from you "scripts": {}in the composer.jsonfile temporarily, and it should be all good.

你可能会删除与脚本@"post-autoload-dump": []从你"scripts": {}的在composer.json文件暂时,它应该是所有好的。

回答by Frédéric Chiasson

You may also try to update your global composerpackage with this command.

您也可以尝试composer使用此命令更新您的全局包。

composer self-update

I was having this error because I had an old version of composer that wasn't reading the @ symbols.

我遇到这个错误是因为我有一个旧版本的作曲家,它没有读取 @ 符号。

回答by zardox

For myself, I found that in composer.json I had the wrong references to the php command: I changed the lines that specified a location for php, for example:

就我自己而言,我发现在 composer.json 中我对 php 命令的引用有误:我更改了指定 php 位置的行,例如:

"@/usr/local/bin/php artisan key:generate"

to:

到:

"@php artisan key:generate"

After those changes, I was able to execute the command "composer update" with no error.

在这些更改之后,我能够毫无错误地执行命令“composer update”。

回答by Sandi Horvat

I have changed

我变了

 "scripts": {
    "post-autoload-dump": [
        "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
        "@/usr/local/bin/php artisan package:discover --ansi"
    ],
    "post-root-package-install": [
        "@/usr/local/bin/php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
        "@/usr/local/bin/php artisan key:generate --ansi"
    ]
}

to

"scripts": {
    "post-autoload-dump": [
        "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
        "@php artisan package:discover --ansi"
    ],
    "post-root-package-install": [
        "@/usr/local/bin/php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
        "@php artisan key:generate --ansi"
    ]
}

in composer.json

在 composer.json 中

回答by Elijah Lynn

I just had this issue trying to add composer native cache-clearcommand to a custom script I made called composer nuke. I was using it as @clear-cacheand got the message, "You made a reference to a non-existent script @clear-cache".

我刚刚在尝试将 Composer 本机cache-clear命令添加到我创建的名为composer nuke. 我正在使用它@clear-cache并收到消息,“您引用了一个不存在的脚本@clear-cache”。

I guess the @symbol is only for custom commands. I had to put composer cache-clearinside the custom command and the error was resolved and the command ran as expected then.

我猜这个@符号仅用于自定义命令。我不得不放入composer cache-clear自定义命令,错误得到解决,命令按预期运行。