discord.js: SyntaxError: Unexpected token '??='

Issue description

4|panais | /home/pi/panais/node_modules/discord.js/src/rest/APIRequest.js:33 4|panais | agent ??= new https.Agent({ …this.client.options.http.agent, keepAlive: true }); 4|panais | ^^^ 4|panais | SyntaxError: Unexpected token ‘??=’ 4|panais | at wrapSafe (internal/modules/cjs/loader.js:1001:16) 4|panais | at Module._compile (internal/modules/cjs/loader.js:1049:27) 4|panais | at Object.Module._extensions…js (internal/modules/cjs/loader.js:1114:10) 4|panais | at Module.load (internal/modules/cjs/loader.js:950:32) 4|panais | at Function.Module._load (internal/modules/cjs/loader.js:790:12) 4|panais | at Module.require (internal/modules/cjs/loader.js:974:19) 4|panais | at Module.Hook._require.Module.require (/usr/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:80:39) 4|panais | at require (internal/modules/cjs/helpers.js:93:18) 4|panais | at Object.<anonymous> (/home/pi/panais/node_modules/discord.js/src/rest/RESTManager.js:4:20) 4|panais | at Module._compile (internal/modules/cjs/loader.js:1085:14)

Code sample

none

discord.js version

13.3.1

Node.js version

16+

Operating system

raspberry

Priority this issue should have

Low (slightly annoying)

Which partials do you have configured?

GUILD_MEMBER, MESSAGE

Which gateway intents are you subscribing to?

GUILDS, GUILD_MEMBERS, GUILD_VOICE_STATES, DIRECT_MESSAGES

I have tested this issue on a development release

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

I get that v16 is a lts version, but I’m curious as to what the intention is behind insisting on such a new version of node is?

Currently I can’t use this library on our stack because we use aws and they only support up to version 14. https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html

Can I use and old release of discord.js that supports v14?

??= is valid syntax and is compatible since late v15 (and in turn, v16.0.0 and newer also support it): https://node.green/#ES2021-features-Logical-Assignment

This operator is called Logical Nullish Assignment, and is being used correctly, as such, this is valid syntax.

It just isn’t in older versions, make sure you’re running the correct version (e.g. your application is running the version you have) and not an older one.