0

When I run my node js app, Heroku reports an error:

/app/node_modules/discord.js/src/rest/APIRequest.js:34
agent ?? = new https.Agent ({... this.client.options.http.agent, keepAlive: true});

SyntaxError: Unexpected token '?? ='

The problem is that even if I comment out this line or delete it, the problem is not solved. And the error will prevent me from running the code.

As far as I understand, this is a new symbol for node js, which is inconsistent with heroku's version of node js, but this is just guesswork. So how do I fix this? Thanks in advance

SHUSTRIK
  • 5
  • 1
  • 4
  • 1
    This is called [Logical nullish assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_nullish_assignment), if you remove the space - What version of node.js are you using? This is only supported in v15+ – evolutionxbox Jan 06 '22 at 15:02
  • @evolutionxbox, i know, but heroku does not work with this. My question not about "what is it?", my question about heroku and work him with this operator. – SHUSTRIK Jan 06 '22 at 15:18
  • It's not a problem of your code, but of the required discord.js package, which needs at least node 16.6. According to the [docs](https://devcenter.heroku.com/articles/nodejs-support#supported-runtimes) heroku should support the latest stable runtime of nodejs. Did you specify an engine in your package.json https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version ? If not, version 14 will be used, as stated in the very same docs ... – derpirscher Jan 06 '22 at 15:22
  • @derpirscher Thanks! You saved life of my project :) – SHUSTRIK Jan 06 '22 at 15:27

0 Answers0