Since the error happens when node tries to parse the [...]/node_modules/mongodb/lib/collection.js:24:18 character, there is a good chance that there is a misconfiguration somewhere. Try to check if the project's setup is compatible with the mongodb version. Usually, from my experience, JS parsing errors inside well stablished modules happens because of misconfigurations. - Iguatemi CG
As per the author's comment, they fixed the issue by downgrading to the following versions:
node - from v22.20.0 to v20.19.5
mongoose - from 8.19.1 to 8.6.0