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

旧城冷巷雨未停 提交于 2020-12-30 19:17:11

问题


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

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

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-update or composer global update not helping.


回答1:


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

If you want to get rid of this warning simply do

composer dump-autoload --no-scripts

or

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




回答2:


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

composer self-update

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




回答3:


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:

"@/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.




回答4:


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




回答5:


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

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



来源:https://stackoverflow.com/questions/48760744/error-you-made-a-reference-to-a-non-existent-script-php-artisan-packagediscov

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!