Recently I encountered this mongoose error CastError: Cast to ObjectId failed for value \”583fe2c488cf652d4c6b45d1\” at path
\”_id\” for model User
In the script, I simply pass the documentId as a string!!
So I run a command
npm list --depth=0
to check the mongodb and mongoose version.
Heres the report:
It seems theres an issue on this mongodb version, so what I did is I uninstall and try to use different version such as 2.2.16
$ npm uninstall mongodb,it will delete the mongodb from your node_modules directory
$ npm install email@example.com
Finally, restart the app and it works fine!
Mongodb error: hex is not a function