Fs is not a function. Why?

Hi, I’m a newbie to Javascript and I’ve been running into problems with the way Glitch works. What usually works on my computer may not work on Glitch. Tried to search on other forums, found nothing.

Here is the code, oversimplified:

const { fs } = require('fs');

const load = (dir = "./commands/") => {
  fs(dir).forEach(dirs => {
    //some code stuff

When calling load, I get an error

fs(dir).forEach(dirs => {
TypeError: fs is not a function

Why is it not working? This same code works perfectly fine on my computer.
Also removing {} in fs declaration makes no difference.

Thank you.

fs does not exort any function fs.
Thus, const fs = require('fs'); should work.
Similarly, if you specifically want to import a method:

const { readdir } = require('fs');
1 Like

I eventually found out myself, but it seems I was late to edit my post.

Thank you very much anyways :smile: