Ask coding questions

← Back to all posts
ReferenceError: __dirname is not defined
KrevLight (1)

When i run the code it doesnt show any errors, but then when i go on discord and do the command /gen netflix it outputs -
const filePath = __dirname + "/" + args[0] + ".txt";

and it outputs this -

Process crashed with: ReferenceError: __dirname is not defined
at Client.bot.on.message (evalmachine.<anonymous>:37:38)
at Client.emit (events.js:198:13)
at MessageCreateHandler.handle (/home/runner/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
at WebSocketPacketManager.handle (/home/runner/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:105:65)
at WebSocketConnection.onPacket (/home/runner/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (/home/runner/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)
at WebSocket.onMessage (/home/runner/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:198:13)
at Receiver.receiverOnMessage (/home/runner/node_modules/ws/lib/websocket.js:789:20)
at Receiver.emit (events.js:198:13)

link : https://repl.it/@KrevLight/AccountGen