I hope this helps, I updated the mongodb version, I tried to install bson but it wasn't compatible and I had installed already mongoose in my project so I extracted the ObjectId from the Types object import { Types } from 'mongoose';
. ex. Types.ObjectId