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

165
Vistas
Trying to use writeFileSync in conjunction with Node Exec to programmatically run tests

I'm trying to create an editor like FreecodeCamp and I ran into an interesting problem. I have my frontend sending a string that I then try to convert into a file using the node process writeFileSync. I then try to call a script programmatically using exec from the child_processes module.

    const str = req.body.code.replace(/"/g, "");
   await fs.writeFileSync('./test/add.js', str)
    await exec('npm run test', (error, stdOut) => {
        console.log('error', error);
        console.log('stdout', stdOut)
        res.json({ message: stdOut })
    })
    

})

If I commit out await fs.writeFileSync('./test/add.js', str) it works perfectly. How can I write a file and then run my script?

about 4 years ago · Juan Pablo Isaza
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