vogler / free-games-claimer

Automatically claims free games on the Epic Games Store, Amazon Prime Gaming and GOG.
GNU Affero General Public License v3.0
2.2k stars 139 forks source link

Unexpected token '||=' on node < 15 #264

Closed jtrull101 closed 6 months ago

jtrull101 commented 7 months ago

Whether using the docker container or locally , I have been seeing this problem:

file:///{PATH}/free-games-claimer/gog.js: 89 db.data[user] ||= {}; ^^^

SyntaxError: Unexpected token '||=' ←[90m at Loader.moduleStrategy (internal/modules/esm/translators.js:145:18)←[39m ←[90m at async link (internal/modules/esm/module_job.js:63:21)←[39m

Same behavior for prime, gog, and epic

jtrull101 commented 7 months ago

Last successful fetch was "2023-11-03 06:30:29.881" according to the epic-games.json log

vogler commented 6 months ago

Can't reproduce. Looks like you use some very old version of node. ||= was added in v15: https://stackoverflow.com/questions/69515305/logical-or-assignment-not-working-on-nodejs

The docker image has a newer version, so idk how that should be possible.

vogler commented 6 months ago

Are you still on bullseye or which OS are you using? https://packages.debian.org/search?keywords=nodejs

See https://nodejs.org/en/download/ for how to install a newer version.

jtrull101 commented 6 months ago

Running on Win 11. Node version reported by gitbash is v14.17.3 The date of the last fetch coincides with some angular work I was doing on my local environment with that node version. Thank you for looking into this

vogler commented 6 months ago

But maybe a good idea to check the node version in the script if that's possible without tripping up the lexer already for old versions.

vogler commented 6 months ago

Yea, as expected, doesn't work: image image https://tio.run/#javascript-node

Could check node -v, but doesn't make sense to have some wrapper for that.

vogler commented 6 months ago

Put the constraint in package.json such that it could be checked for #219 or npx.