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

130
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
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