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

210
Vistas
nodejs debug - save state of the script (with all objects and var values) and use it on next run

When I run the script, my application first creates an object that I will use in all my applications.

Object creation takes up to 10 seconds. So when I try to test any new piece of code, I have to wait 10 seconds each time.

The app is going to be big enough, I can't wait that long when I add a new line of code. How to deal with this? Is there a way to save the state of the script from some point and run it every time from the point with this "heavy" object already initialized.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Assuming that heavy object is something that will not change often, you could try exporting it like this

const heavyObj = {};
module.exports = heavyObj ;

After that import the object wherever you need

const heavyObj = require('./data.js')
about 4 years ago · Juan Pablo Isaza Denunciar
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