Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

447
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!