0

I keep on getting error stating...

Debugger attached.
Waiting for the debugger to disconnect...
c:\Users\Administrator\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\Administrator\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)

I don't know why syntax error, my code itself does not have that syntax error I think it's with the Discord.Js module itself, how do I fix this?

AidanGamin
  • 67
  • 1
  • 7
  • 1
    If you properly read the guide, it does mention for a support at the least of node v16.0.0, any version lower than that will result in these errors. – Jeffplays2005 Oct 11 '21 at 10:04
  • 2
    Does this answer your question? [Nullish coalescing assignment operator (??=) in NodeJS](https://stackoverflow.com/questions/67959998/nullish-coalescing-assignment-operator-in-nodejs) – MrMythical Oct 11 '21 at 11:38

1 Answers1

5

This is not a syntax error, it's just a support problem

This assignment is called Logical nullish assignment check this MDN ref to understand the behavior and the browser support

And for Nodejs version support - which is causing the issue for you - check this Node Green table, you can see that you need nodejs higher than v15.0.0 so this assignment can work fine.

Zac
  • 1,497
  • 9
  • 11
  • I'm using version 16.9 and no luck. Btw I'm install the node using nvm on linux subsystem. Any other suggestion? – Shaf Dec 14 '22 at 05:28