Getting this error. my typescript version is 4.5.4 and "@types/mongodb": "~3.3.1",
"@types/mongoose": "~5.5.17". any idea how to solve
enter code here
../@types/mongodb/index.d.ts:49:74 - error TS2724: '"bson"' has no exported member named 'ObjectID'. Did you mean 'ObjectId'?
49 export { Binary, DBRef, Decimal128, Double, Int32, Long, MaxKey, MinKey, ObjectID, ObjectId, Timestamp } from 'bson';
~~~~~~~~
../bson/bson.d.ts:939:22
939 export declare class ObjectId extends BSONValue {
~~~~~~~~
'ObjectId' is declared here.
3
Answers
Downgrading to version 6.8.3 solved the problem for me .I think there might be a bug with the current version of mongoose. Or the current version has compatibility issues with some of its dependencies .
This is because using bson 5.0.0 removed ObjectID which breaks everything that referenced it before. Force your program to use bson 4.7.2.
Explicitly installing an older version of the MongoDB types that matches your installed version of the
mongodb
Node module may work. For example: