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

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