I have Laravel Breeze running on Homestead. I've noticed the the dropdown functionality from the menu is not working and checked the console log in the browser where I got:
Uncaught ReferenceError: require is not defined :build/assets/app-f35e98d6.js:1
I've checked the compiled JS file and it has something like this:
window._=require("lodash");window.axios=require("axios");
My package.json looks like this:
{
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build --watch"
},
"devDependencies": {
"@tailwindcss/forms": "^0.5.2",
"alpinejs": "^3.4.2",
"autoprefixer": "^10.4.2",
"axios": "^1.1.2",
"laravel-vite-plugin": "^0.7.2",
"postcss": "^8.4.6",
"tailwindcss": "^3.1.0",
"vite": "^4.0.0"
},
"dependencies": {
"lodash": "^4.17.21"
}
}
And this is the config file for vite
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
plugins: [
laravel({
input: [
'resources/css/app.css',
'resources/js/app.js',
],
refresh: true,
}),
],
});
And just in case if it is needed - composer.json
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"php": "^8.1",
"doctrine/dbal": "^3.6",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^10.8",
"laravel/sanctum": "^3.2",
"laravel/tinker": "^2.8",
"spatie/laravel-permission": "^5.10"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"laravel/breeze": "^1.20",
"laravel/pint": "^1.0",
"laravel/sail": "^1.18",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^7.0",
"pestphp/pest": "^2.0",
"pestphp/pest-plugin-laravel": "^2.0",
"spatie/laravel-ignition": "^2.0",
"vkovic/laravel-commando": "^0.2.1"
},
"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 --force"
],
"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,
"allow-plugins": {
"pestphp/pest-plugin": true,
"php-http/discovery": true
}
},
"minimum-stability": "stable",
"prefer-stable": true
}
I don't get any errors while running npm run dev
or npm run build
. I have tried running both from the vagrant
and from my home
(my OS is Linux), and still having the issue. I haven't edit any of the JS files that came with Breeze, and I haven't added any other JS.