Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

151
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda