Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

580
Views
Error de referencia no detectado: swal: Sweetalert2 con el proyecto laravel no funciona

Estoy usando sweetalert 2 con el proyecto laravel, funciona bien cuando estoy usando un enlace CDN , pero no funciona después de la instalación a través npm install --save sweetalert2 y da el siguiente error.

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

(anónimo) @ publicaciones: 1441

mi código:

1: con 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>

esto funciona bien, pero no quiero usar cdn.

2: hasta npm:

pasos

Primero

 npm install --save sweetalert2

Segundo en app.js

 import Swal from 'sweetalert2';

Tercero

 npm run dev

Pero no funciona.

¿Cómo podemos resolver el problema?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!