How do I make asset() work correctly in Laravel 8.x?

You need to use the compiled version of the file /resources/assets/js/app.js.

npm run dev or npm run watch to compile the assets which will create corresponding app.js file in /public/js/app.js folder

Use this in your script tag

<script src="{{ asset('js/app.js') }}"></script>