problem with "ReferenceError: fs is not defined"

Viewed 21

so ive been trying to fix this problem for the past hour and can get it to work, its probably a stupid mistake, but what you see here is my fs.readdir is defined.

vsc error + code

2 Answers

You need to import fs. Put this above line 25 or your first use of fs

const fs = require('fs');

If you still don't install the fs package, go to terminal then type npm install fs

  1. Click on Terminal
  2. On your keyboard command Ctrl + C if your bot is running
  3. type npm install fs or npm i fs
  4. On your code now type const fs = require('fs');

You can put it on line 13 in your js file

Related