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

136
Visualizações
Visual Studio Code - Formatting code styling

I am typing this in Visual Studio Code

const tours = JSON.parse(fs.readFileSync(`${__dirname/dev-data/data/tours-simple.json}`));

But when I save the file, my tours constant changes to this

const tours = JSON.parse(fs.readFileSync(`${__dirname / dev - data / data / tours - simple.json}`));

That makes my code non functional. How to remove the white spaces?

Thanks, Theo.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You aren't writing the path in correctly - when you put it inside ${var}, this denotes to JS that you want to escape that bracket from a string, and into a variable called var. JS will get the value of var and put it back into the string.

Example:

const a = 'a'
console.log(`${a}b`) // Prints 'ab'
about 4 years ago · Juan Pablo Isaza Relatório

0

Your closing } character is in the wrong place. It's at the end of the string, when it should actually come right after the __dirname variable. Try this instead:

const tours = JSON.parse(fs.readFileSync(`${__dirname}/dev-data/data/tours-simple.json`));
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