fs.mkdir()和fs.writeFile()在Glitch托管中不起作用

问题描述 投票:0回答:1

我有一个故障应用程序,它必须创建目录和文件来存储数据,当我在Heroku中运行时,它都运行良好,但是现在,我已更改为故障处理,它不起作用。阅读日志,我认为Glitch不允许我的程序创建文件夹和文件,日志:

{ Error: ENOENT: no such file or directory, mkdir './files/665290737256103949'
    at Object.mkdirSync (fs.js:752:3)
at Object.execute (/app/commands/condenar.js:39:12)
at Client.bot.on.message (/app/index.js:106:37)
    at Client.emit (events.js:189:13)
    at MessageCreateHandler.handle (/rbd/pnpm-volume/68c8ba02-3c6e-4076-88e9-cde586593473/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
    at WebSocketPacketManager.handle (/rbd/pnpm-volume/68c8ba02-3c6e-4076-88e9-cde586593473/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:108:65)
    at WebSocketConnection.onPacket (/rbd/pnpm-volume/68c8ba02-3c6e-4076-88e9-cde586593473/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:336:35)
    at WebSocketConnection.onMessage (/rbd/pnpm-volume/68c8ba02-3c6e-4076-88e9-cde586593473/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:299:17)
    at WebSocket.onMessage (/rbd/pnpm-volume/68c8ba02-3c6e-4076-88e9-cde586593473/node_modules/discord.js/node_modules/ws/lib/event-target.js:120:16)
    at WebSocket.emit (events.js:189:13)
  errno: -2,
  syscall: 'mkdir',
  code: 'ENOENT',
  path: './files/665290737256103949' }
(node:28673) DeprecationWarning: Collection#find: pass a function instead
(node:28673) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send messages to this user
    at item.request.gen.end (/rbd/pnpm-volume/68c8ba02-3c6e-4076-88e9-cde586593473/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15)
    at then (/rbd/pnpm-volume/68c8ba02-3c6e-4076-88e9-cde586593473/node_modules/discord.js/node_modules/snekfetch/src/index.js:215:21)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:28673) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:28673) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:28673) DeprecationWarning: Collection#find: pass a function instead
javascript node.js file hosting fs
1个回答
0
投票

小故障确实允许写入和读取文件。您应该重新看一下自己拥有的东西。实际上,故障内置了fs,因此您甚至不需要npm安装它。

© www.soinside.com 2019 - 2024. All rights reserved.