Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

303
Visualizações
Error: export 'default' (imported as 'Swal') was not found in 'sweetalert2' (module has no exports)

I am trying to include sweetalert2 in my Angular project, but it gives compile time error. The error /src/app/pages/signup/signup.component.ts:29:16-25 - Error: export 'default' (imported as 'Swal') was not found in 'sweetalert2' (module has no exports)

step follow

1.install sweetalert2 2.import on component .ts file (import Swal from 'sweetalert2') 3.call by using Swal.fire()

/src/app/pages/signup/signup.component.ts:29:16-25 - Error: export 'default' (imported as 'Swal') was not found in 'sweetalert2' (module has no exports)

anyone having solution?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I had this exact same error, problem was that I was exporting the component as:

const Component = () => { Swal.fire({ //configs... }) 

export default Component;

I deleted that last line and changed to:

export const Component = () => { Swal.fire({ //configs... })

And everything started to work again.

about 4 years ago · Juan Pablo Isaza Relatório

0

  1. So you need to first make sure of that you are including the required css & js files in angular.json/angular-cli.json (depending upon your ng version)
  "styles": [
        "../node_modules/sweetalert2/dist/sweetalert2.css"
      ],
      "scripts": [
        "../node_modules/sweetalert2/dist/sweetalert2.js",
      ],
  1. then, in your component, you can import it like this
import swal from "sweetalert2";
  1. And in your component you can use it like this
swal({
     type: 'success',
     title: 'your message',
     showConfirmButton: false,
     timer: 1500
   });
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda