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

211
Visualizações
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 Respostas
Responde à pergunta

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 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