You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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); }); });
The text was updated successfully, but these errors were encountered:
generally fs cannot be used in browsers or adequately transformed beforehand (as accessing the user's filesystem from a browser is impossible). brfs only supports specific patterns that are common in npm modules, so calls to fs.readFile() with constant parameters. it's kinda the equivalent of "importing" a file as a string/arraybuffer. brfs can't access runtime values so it can't transform things like fs.readFile(someDynamicValue). fs.readdir is not supported because the other restrictions in brfs make it useless. hopefully that explains the limitations at least!
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); }); });
The text was updated successfully, but these errors were encountered: