1

我正在使用 Laravel 版本8.53.1,并且我已经尝试了这些命令来使用 Laravel 安装 Bootstrap 身份验证:

composer require laravel/ui
php artisan ui bootstrap 
php artisan ui bootstrap --auth
npm install  && npm run dev 

但现在的问题是 Login & Register 刀片不读取 Bootstrap,表单如下所示:

截屏

我什至多次重复运行该命令,但问题仍然存在!这里出了什么问题?

作曲家.json

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "require": {
        "php": "^7.3|^8.0",
        "fideloper/proxy": "^4.4",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^7.0.1",
        "laravel/framework": "^8.40",
        "laravel/tinker": "^2.5",
        "laravel/ui": "^3.4",
        "maatwebsite/excel": "^3.1"
    },
    "require-dev": {
        "facade/ignition": "^2.5",
        "fakerphp/faker": "^1.9.1",
        "laravel/sail": "^1.0.1",
        "mockery/mockery": "^1.4.2",
        "nunomaduro/collision": "^5.0",
        "phpunit/phpunit": "^9.3.3"
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/",
            "Database\\Factories\\": "database/factories/",
            "Database\\Seeders\\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-update-cmd": [
            "@php artisan vendor:publish --tag=laravel-assets --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

包.json

{
    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "mix",
        "watch": "mix watch",
        "watch-poll": "mix watch -- --watch-options-poll=1000",
        "hot": "mix watch --hot",
        "prod": "npm run production",
        "production": "mix --production"
    },
    "devDependencies": {
        "@popperjs/core": "^2.10.2",
        "axios": "^0.21",
        "bootstrap": "^5.1.3",
        "laravel-mix": "^6.0.6",
        "lodash": "^4.17.19",
        "postcss": "^8.1.14",
        "resolve-url-loader": "^4.0.0",
        "sass": "^1.32.11",
        "sass-loader": "^11.0.1"
    }
}

那么我该如何解决这个问题呢?我也尝试通过运行php artisan cache:clearand来删除缓存php artisan view:clear,但它并没有解决问题。

4

2 回答 2

1

当您运行第一个时npm install && npm run dev,会出现一条消息以安装额外的包/依赖项并npm run dev再次运行。步骤是:

  • npm install resolve-url-loader@^4.0.0 --save-dev --legacy-peer-deps
  • npm run dev

附加包/依赖项的屏幕截图

于 2022-01-02T00:34:32.827 回答
0

第一次npm run dev安装 Laravel 和laravel/ui和 Bootstrap 包时,它不会编译资源。相反,您会收到如下消息。

必须安装其他依赖项。这将只需要片刻。运行: npm install resolve-url-loader@^4.0.0 --save-dev --legacy-peer-deps 完成。请再次运行 Mix。

该消息要求您再次运行 Laravel Mix。再次运行npm run dev以完成资产的编译。

在此处输入图像描述

于 2022-01-01T18:36:58.340 回答