Hello Geek, here are the steps on how to install JQuery in Laravel Vite:
- Open a terminal window and navigate to the root directory of your Laravel project.
- Run the following command to install JQuery:
Code snippet
npm install jquery
- Import JQuery in your
bootstrap.js
file:
Code snippet
import $ from 'jquery';
window.$ = $;
- Load your
bootstrap.js
file using the@vite
Blade directive:
Code snippet
@vite(['resources/js/bootstrap.js'])
- Now you can use JQuery in your Laravel application.
Here are some additional notes:
- You can also import JQuery in your
app.js
file. - If you are using a Laravel Mix configuration file, you can add JQuery to the
dependencies
section. - You can also use a CDN to load JQuery.
All the best nerd!