arangodb / arangojs

The official ArangoDB JavaScript driver.
https://arangodb.github.io/arangojs
Apache License 2.0
600 stars 106 forks source link

Invalid token while loading arangojs module in nodejs - collection.js, cursor.js, and graph.js - syntax error #785

Closed ddesai11 closed 1 year ago

ddesai11 commented 1 year ago

The nodejs app won't start due to loading error in arangojs module. There are three javascript files collection.js, cursor.js, and graph.js which have syntax error. example, collection.js:

line# 288, 296, 309, 317, 330, 338, 350, 358 }, (res) => (options?.silent ? undefined : res.body));

I manually fixed locally by removing ? as }, (res) => (options.silent ? undefined : res.body));

The other javascript files have similar issue, by fixing it manually, I was able to load and use arangojs successfully.

pluma4345 commented 1 year ago

Which node version is this?

pluma4345 commented 1 year ago

The problem you're seeing is from your Node.js version not supporting the "optional chaining operator". This feature is supported in all active LTS versions of Node.js: https://node.green/ The oldest supported LTS version is Node.js 14, which is in its maintenance phase, ending this month: https://nodejs.dev/en/about/releases/

Based on the error you're seeing I think you may be using Node.js 12 or older. These versions are no longer maintained by the Node.js project and don't receive updates. I would strongly advise upgrading to Node.js 18, which is the current LTS release. Node.js 16 will reach its EOL later this year too.

If you're seeing this error in Node.js 14 or later, feel free to reopen this issue as that should not happen.