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

201
Views
How would I load an ogg file in node js

My goal is to load ogg files in node.js I've tried ReadFile but hits me up with this error: Could not read file. [Error: ENOENT: no such file or directory, open 'Main\game\songs\test\Voices.ogg'] and the file does exist.

Code:

fs.readdir('./game/songs', function(err, files){
        if (err) {
            console.log("Could not list the directory.", err)
            return
        }
        files.forEach(function(file, index){
            fs.readFile('./game/songs/'+file+"/Inst.ogg", function(err, data){
                if (err) {
                    console.log("Could not read file.", err)
                    return
                }
            })
            fs.readFile('./game/songs/'+file+"/Voices.ogg", function(err, data){
                if (err) {
                    console.log("Could not read file.", err)
                    return
                }
            })
        })
    })
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You should pass the absolute path of the file, use the built-in path module's join() function:

const path = require('path');
const fs = require('fs');

fs.readFile(path.join(__dirname, 'YOUR_PATH_HERE'), function(err, data) {});
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!