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

139
Visualizações
Why absolute-path is not working in my project?

the hierarchy of my files looks something like:

BACKEND(COMPLETE)
->Routers
   ->userrouter.js
->login.html

I wanted the access of my login.html file in userrouter.js for which I copied the Path(absolute) of the login.html file.

But I am getting this error:

path must be absolute or specify root to res.sendFile()

My Code:

function loginUser(req,res)
{
res.sendFile('C:\Users\ASUS\Desktop\backend(complete)\login.html');
res.end();
}
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Try modifying C:\Users\ASUS\Desktop\backend(complete)\login.html to C:/\Users/\ASUS/\Desktop/\backend(complete)/\login.html

Try using path (path.join) npm package which Node provides out of the box to avoid this confusion irrespective of the OS.

about 4 years ago · Juan Pablo Isaza Relatório

0

Try the Npm package path and use path.join(["yourpath", "here") for cross system compatibility. Note that every part between slashes needs to be its own entry in the array.

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