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

170
Vistas
Check if an asset exists before dinamically importing it

Hello I'm trying to dynamically import a file and if it doesn't than I'm going to create it. But how can I import it only if it exists? This code is throwing me a 500 server error when I try to import a not existing yet file. This is my code (I'm using Vite to serve my app)

import(`./../Cache/${component.type.name}.svg?raw`)
.then(svgCode => console.log(svgCode))
.catch(err => {
    //here the file is created if it doesn't exists but it still throwing an error in the console
  })

It's not only about the error in the console, Vite is also throwing me this message:

ENOENT: no such file or directory, open '/Atlantide/SvgRender/Cache/PixelGrid.svg' Click outside or fix the code to dismiss. You can also disable this overlay by setting server.hmr.overlay to false in vite.config.js.

But I don't wanna disable HMR in my setup, any advice?

about 4 years ago · Santiago Trujillo
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