Click here to Skip to main content
15,946,342 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I've been having some issues with a javascript project lately, I kept getting the referenceError "require is not defined" because I am running the project from a web browser.

To fix that I started using the Browserify module so now the 'require' keyword is working, BUT about two lines of code down I get a new error "fs.readdirSync is not a function"

What I have tried:

Apparently Browserify has another module called brfs which is made specifically to solve the problem I'm having. Except it doesn't work. It doesn't seem to do anything really and the documentation on it is fairly useless.

Does anyone know how to properly use the brfs module to resolve the "fs.readdirSync is not a function" TypeError?
Updated 21-May-23 21:42pm

1 solution

You cannot read the client's file-system from JavaScript running in a browser, except in extremely limited circumstances[^].

No module will provide a "workaround" to bypass this security limitation.

You need to rethink your approach.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900