Node app - SyntaxError: Unexpected token

Thank you. it worked for me

Thankyou so much it worked for me time saver :slight_smile:

I had this issue. error shows

node_modules/bson/lib/bson.cjs:479
        inspect ??= defaultInspect;
                ^^^

SyntaxError: Unexpected token '??='

i am using ubuntu 20.04. its a hosting server in aws.
node -v 14.21.3
mongoDB -v 7.0.4
mongosh -v 2.1.1

please help me…

Answered on the new topic thread that was created.

Thank you very much. In this version, the app is working well…

1 Like

Thansk so much @Sinmbf_Lost

I was facing the same issue and after trying different approaches, the one that worked for me was using mongoose version 7.6.3

An easy solution to this is to get the latest version number from the docker. For me, it was version “21”.
Just go to the Dockerfile and edit this line:
FROM node:21
It will work

1 Like

I encountred the same error, to resolve this, I upgraded from Node.js version 14 to version 18, I deleted the package-lock.json file and the node_modules directory. Afterwards, I reinstalled the dependencies, which effectively fixed the errors.

For me its node js version problem I was using 14 and now using 18V