Laravel 8 中未找到特征 'Laravel\Sanctum\HasApiTokens'

Trait 'Laravel\Sanctum\HasApiTokens' not found in Laravel 8

如果您能帮助我解决我在尝试安装 Laravel (8) jetstream 后遇到的问题,我将不胜感激。

我收到这个错误:

Symfony\Component\ErrorHandler\Error\FatalError
Trait 'Laravel\Sanctum\HasApiTokens' not found 

我之前做的是安装 Laravel 到我的服务器:

composer create-project --prefer-dist laravel/laravel project

composer require laravel/jetstream

php artisan jetstream:install livewire --teams

npm install

npm run dev

php artisan migrate

正如我在文档中读到的那样 (https://jetstream.laravel.com/1.x/introduction.html)。

我的用户模型:

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticable;
use Illuminate\Notifications\Notifiable;
use Laravel\Fortify\TwoFactorAuthenticatable;
use Laravel\Jetstream\HasProfilePhoto;
use Laravel\Jetstream\HasTeams;
use Laravel\Sanctum\HasApiTokens;

class User extends Authenticatable
{
    use HasApiTokens;
    use HasFactory;
    use HasProfilePhotos;
    use HasTeams;
    use Notifiable;
    use TwoFactorAuthenticatable;

更新:

如果 Laravel 已安装,则没有问题:

laravel 新项目名称 --jet

您还需要安装 Sanctum:

composer require laravel/sanctum