Target class [Spatie\Permission\Middleware\RoleMiddleware] does not exist.
In their document maybe you should see,
// Laravel 9 uses $routeMiddleware = [
//protected $routeMiddleware = [
// Laravel 10 uses $middlewareAliases = [
protected $middlewareAliases = [
// ...
'role' => \Spatie\Permission\Middleware\RoleMiddleware::class,
'permission' => \Spatie\Permission\Middleware\PermissionMiddleware::class,
'role_or_permission' => \Spatie\Permission\Middleware\RoleOrPermissionMiddleware::class,
];
But it would be
// Laravel 9 uses $routeMiddleware = [
//protected $routeMiddleware = [
// Laravel 10 uses $middlewareAliases = [
protected $middlewareAliases = [
// ...
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,
'role_or_permission' => \Spatie\Permission\Middlewares\RoleOrPermissionMiddleware::class,
];
Just add extra 's' there.
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,