Skip to content

Still saying fs.readdir is not a function #99

Open
@lowenfas

Description

@lowenfas

I'm fairly new to these modules and NPMs but I've been getting along okay until now, this module seems like it's exactly what I need to fix my TypeError: fs.readdir is not a function. The problem is brfs isn't doing anything and the description/examples are not helping me at all.

How the hell am I supposed to use this module?

The only other thing I can say is that I did install brfs, it is in my dependencies alongside browserify, and the command I use in terminal to output my project is "browserify -t brfs main.js > bundle.js"
Below is my code, I tried some other lines even closer to the examples given but they also did not work, just gave me more errors. What am I missing? Thanks in advance.

const path = require('path'); const fs = require('fs'); // READS ALL FILES IN VIDEO FOLDER // //joining path of directory const directoryPath = path.join(__dirname, './Videos'); //passsing directoryPath and callback function fs.readdir(directoryPath, function (err, files) { //handling error if (err) { return console.log('Unable to scan directory: ' + err); } //listing all files using forEach files.forEach(function (file) { // Do whatever you want to do with the file console.log(file); }); });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions