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

586
Vistas
Uncaught ReferenceError: swal : Sweetalert2 with laravel project is not working

I am using sweetalert 2 with laravel project, it works fine when I am using CDN link, but it does not work after installation through npm install --save sweetalert2 and gives the following error.

posts:1441 Uncaught ReferenceError: swal is not defined
at posts:1441:23

(anonymous) @ posts:1441

my code:

1: with cdn

   <script src="//cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<script>
    const Toast = swal.mixin({
        toast: true,
        position: 'top-right',
        showConfirmButton: false,
        showCloseButton: true,
        timer: 5000,
        timerProgressBar: true,
        didOpen: (toast) => {
            toast.addEventListener('mouseenter', Swal.stopTimer)
            toast.addEventListener('mouseleave', Swal.resumeTimer)
        }
    });

    window.addEventListener('alert', ({
        detail: {
            type,
            message
        }
    }) => {
        Toast.fire({
            icon: type,
            title: message
        })
    })
</script>

this works fine, but i dont want to use cdn.

2: through npm:

steps

First

npm install --save sweetalert2

Second in app.js

import Swal from 'sweetalert2';

Third

npm run dev

but it does not work.

how can we solve the problem?

about 4 years ago · Juan Pablo Isaza
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