-1

When I run discord bot with discord.js

[my\path\discord.js\bot]
> node bot.js
C:\Users\username\node_modules\discord.js\src\rest\APIRequest.js:33
    agent ??= new https.Agent({ ...this.client.options.http.agent, keepAlive: true });
          ^^^

SyntaxError: Unexpected token '??='
    at wrapSafe (internal/modules/cjs/loader.js:1001:16)
    at Module._compile (internal/modules/cjs/loader.js:1049:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.<anonymous> (C:\Users\username\node_modules\discord.js\src\rest\RESTManager.js:4:20)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)

[my\path\discord.js\bot]

>

I think it's rest client syntax error How can I fix it?

ywbird
  • 105
  • 5

1 Answers1

1

Assuming this is Discord.js v13, you need to be using Node 16.6.0+ as stated in the docs. The error you're receiving is most likely due to your Node version being below that since ??= should work if you're using the right version of node.

Logical nullish assigment (??=) is relatively new to Node (15.14.0 according to node.green), you need to update it to at least 16.6.0 for Discord.js v13 to fully function.

iiRealistic_Dev
  • 381
  • 3
  • 8