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

144
Views
error <function name> is not a function when importing javascript functions from another file

Im trying to setup an express api for my application and using functions i've already defined in another js file for my api calls.

When I try running this post request i get the error

date is not a function name

I figured there's something wrong with the way im importing my functions and using them

this is how I did the import and used the function

const {captures,date} =require ("..\\..\\captures.js");
module.exports={
   visualtest:function(req,res){
        captures("C:\\Users\\rami.benromdhane\\Desktop\\dh_automation_test_suites\\json\\report1.json","ref","..\\static\\captures",date(req.body.report1));
        captures(req.body.report2,test,"..\\static\\captures",date(req.body.report2));
        
        
}
}

this is how my functions or defined in captures.js

 function captures(reportjson,testorref,resultpath,date){...}
function date(report){...}

I tried using import from instead of require but then i get the error can t use import statement outside of module

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