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

244
Views
When I try to define settings, I get a different error
var fs = require('fs');
const yaml = require('js-yaml');
const settings = yaml.load(fs.readFileSync('../settings.yml', 'utf8'));
const {car} = require('./car-bmw.js');

function log() {
    console.log("Car name:" + settings.space + car.name);
    console.log("Car model:" + settings.space + car.model);
    console.log("Car color:" + settings.space + car.color);
};

try {
    log();
} catch (error) {
    console.log(`${settings.errorMessage}`);
    console.error(error);
}[e][1]

When I try to run this script, I get the error Uncaught Error: ENOENT: no such file or directory, open './settings.yml' and Process exited with code 1 . Anybody can help?

directory,folder

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The path is incorrect in the filesync, you can use path.join

var fs = require('fs');
const yaml = require('js-yaml');
const path = require('path');

// file will be picked up if it is in same directory
// else you need to provide the relative path and path.join will 
// create a correct path for it

const settings = yaml.load(fs.readFileSync(path.join(__dirname, '/settings.yml'), 'utf8'));
const {car} = require('./car-bmw.js');

function log() {
    console.log("Car name:" + settings.space + car.name);
    console.log("Car model:" + settings.space + car.model);
    console.log("Car color:" + settings.space + car.color);
};

try {
    log();
} catch (error) {
    console.log(`${settings.errorMessage}`);
    console.error(error);
}[e][1]
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!