【问题标题】:I need some an error with Discord.js v12 and the database我需要 Discord.js v12 和数据库的一些错误
【发布时间】:2021-05-07 08:40:32
【问题描述】:

每次我尝试部署我的不和谐机器人时都会收到此错误。我一直在尝试,但我希望有人比我更有经验。

错误:

                client.database?.init();
22:34:56.146                    ^
22:34:56.146    SyntaxError: Unexpected token '.'
22:34:56.146        at wrapSafe (internal/modules/cjs/loader.js:915:16)
22:34:56.146        at Module._compile (internal/modules/cjs/loader.js:963:27)
22:34:56.146        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
22:34:56.146        at Module.load (internal/modules/cjs/loader.js:863:32)
22:34:56.146        at Function.Module._load (internal/modules/cjs/loader.js:708:14)
22:34:56.146        at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
22:34:56.146        at internal/main/run_main_module.js:17:47
22:34:56.150    Error: Command "node ." exited with 1

【问题讨论】:

  • 请分享更多详细信息,例如涉及的代码以及您解决问题的尝试

标签: javascript node.js mongodb mongoose discord.js


【解决方案1】:

Optional chaining? in client.database?.init();)仅在 Node.js v14 中可用,因此请确保您使用的是最新的 LTS(目前为 v14.15.4)。

您可以从their site 下载最新版本的 Node.js,甚至更好,您可以使用 Node 版本管理器(如 nvm)来管理多个活动的 Node 版本。

【讨论】:

    猜你喜欢
    • 2021-06-28
    • 2010-11-10
    • 2020-10-09
    • 2020-10-25
    • 2021-02-27
    • 2021-05-16
    • 1970-01-01
    • 2011-02-27
    • 2020-10-23
    相关资源
    最近更新 更多