'Laravel PackageManifest.php line 131: Undefined index: name

I updated the composer with this command:

composer self-update

It was updated to version 2.0.4. Then when I tried to launch my Laravel project using:

php artisan serve

I got this error:

In PackageManifest.php line 131:

 Undefined index: name

I tried getting back to the old version of the composer with this:

composer self-update --rollback

The composer was downgraded to version 1.9.3, but it didn't help with the error. Then I used this command to update the composer again:

composer self-update --stable

And still got the same error.

This is the line 131 of the PackageManifest.php file:

return [$this->format($package['name']) => $package['extra']['laravel'] ?? []];


Solution 1:[1]

The issue is one of the Laravel default vendor packages has a small bug.

The solution to fix this is the following:

rm -rf composer.lock
rm -rf vendor
composer install

This will update the composer packages to the latest versions for your current version of laravel and this should resolve the issue.

Solution 2:[2]

This was actually fixed in Laravel already, so please make sure you update Laravel to at least 6.18.7+ or 7.6.0+ or 8.0+

FYI, if you remove composer local file, it will update all your dependencies, so it's not a good idea.

By running the command composer update laravel/framework should hopefully fix the issue and not cause any other problems. If you can not update Laravel then you better off downgrade to Composer 1 using composer self-update --1.

If you are using illuminate/foundation instead of laravel/framework, then make sure you composer update illuminate/foundation instead.

Solution 3:[3]

add code in Illuminate\Foundation\PackageManifest.php about to line 129:

    ...
    $ignoreAll = in_array('*', $ignore = $this->packagesToIgnore());
    // ------------------:::::::::FIX::::::::::------------
    if (isset($packages['packages'])){
        $packages = $packages['packages'];
    }
    // ---------------------------ENDFIX-------------------
    $this->write(collect($packages)->mapWithKeys(function ($package) {
    ...

Solution 4:[4]

Option 1:

Open vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php

then search code :

$packages = json_decode($this->files->get($path), true);

insert

$packages = $installed['packages'] ?? $installed;

Option 2 :

run command

composer update

Solution 5:[5]

this helped me :

downgrade to Composer 1 using

composer self-update --1 

Solution 6:[6]

I also faced the same issue and the following code worked for me

  1. rm -rf composer.lock
  2. rm -rf vendor
  3. composer install

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Sethu
Solution 3 Solo.dmitry
Solution 4 Son Andreas
Solution 5 saber tabatabaee yazdi
Solution 6 sajjadkhan