Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

131
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!