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

456
Vistas
Javascript - Perform several functions in a row && Error: ENOENT: no such file or directory

I have created in my project several separate functions in separate files that I import with module.exports.$functionName

I then compile everything in an index.js file. This is the problem. The first function allows to download a file, without which the two other functions can't work. I tried to use the promises to wait for the download, but the file does not download and this error appears:

Error: ENOENT: no such file or directory

Here is the code, I specify that each function works when you run them independently:

const mt = require("./mainTweet"); // from mainTweet.js 
const rp = require("./Reply"); // from Reply.js
const od = require("./getcsv") // from getcsv.js

function Download() {
  return new Promise((resolve) => {
    od.onDownload();
    resolve();
  });
}

function firstTweet() {
  return new Promise((resolve) => {
    mt.getData()
    resolve();
  });
}

function secondTweet() {
  rp.Reply();
}

async function Launch() {
  await Download();
  await FirstTweet();
  Reply();
}

Launch();
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Since you answered in a comment that od.onDownload, mt.getData and rp.Reply are async, the problem is that you do not await them.

When you do this:

od.onDownload()
resolve()

onDownload() will run and return a promise immediately and then you resolve your own promise. This means that onDownload has not yet resolved (or thrown). You should instead await each call. You could simplify your whole code to this:

const mt = require("./mainTweet"); // from mainTweet.js 
const rp = require("./Reply"); // from Reply.js
const od = require("./getcsv") // from getcsv.js

async function Launch() {
  await od.Download();
  await mt.getData();
  rp.Reply()
}

Launch();
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