Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

191
Vistas
Problem using sweetalert2 and filepond in Laravel 9.2

Hell guys ,

I am using Laravel 9 and I want to use sweetalert2 and filepond in my project. I installed the mentioned plugins through npm. This is my app.js file

import './bootstrap';

import Alpine from 'alpinejs';

import * as FilePond from 'filepond';
import Swal from 'sweetalert2';

import 'filepond/dist/filepond.min.css';

window.Alpine = Alpine;
window.FilePond = FilePond;
window.Swal = Swal;

I also included this in head tag

 @vite(['resources/css/app.css', 'resources/js/app.js'])

I also run this command in terminal without any error.

npm run dev

This is my script tag for sweetalert2.

@if(Session::has('status'))
   // This works but I don't want it -> {{-- <script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script> --}} 

  // This one is not working            
  <script>
                Swal.fire({
                    toast: true,
                    position: 'top-end',
                    icon: 'success',
                    title: "{{Session::get('status')}}",
                    showConfirmButton: false,
                    timer: 1500
                })
  </script>
@endif

This is my script tag for filepond.

<script>
        // Get a reference to the file input element
        const inputElement = document.querySelector('input[type="file"]');
        
        // Create a FilePond instance
        const pond = FilePond.create(inputElement);
</script>

I also get this error after using sweetalert2 or filepond

  • Uncaught ReferenceError: Swal is not defined
  • Uncaught ReferenceError: FilePond is not defined

Is it because of the vite?

How can I fix this?

I used sweetalert2 in my previous project in Laravel 8.x and that was working and the app.js file looked like this.

require('./bootstrap');
window.Swal = require('sweetalert2')
import Alpine from 'alpinejs';

window.Alpine = Alpine;

Alpine.start();

This require function is not working in Laravel 9.2 and I get the same error require is not defined.

about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda