Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongoose Namespace has no exported member 'OptionalId'

I am getting this error while i run npm i.

../@types/mongoose/index.d.ts:191:17 - error TS2694: Namespace '"/Users/test-service/node_modules/@types/mongodb/index"' has no exported member 'OptionalId' ? mongodb.OptionalId & { _id: TId }>

I am using "@types/mongoose": "^5.5.32", "@types/mongodb": "~3.3.1". Can someone help me solving this problem. my tsc version is Version 3.8.3 .

like image 784
Somesh Paradkar Avatar asked Jun 08 '20 16:06

Somesh Paradkar


2 Answers

I just solved the problem by running this command.

npm install --save @types/mongodb

Hope this can help you.

like image 51
Luca Iaconelli Avatar answered Nov 15 '22 09:11

Luca Iaconelli


Why ?

my project node_modules like this,

  • node_modules
    • @types/mongoose/@types/mongodb
    • @types/mongodb

@types/mongoose has @types/mongodb dependencie, and it has conflict with @types/mongodb.

How to Fix

Run this command at your node_modules directory:

$ rm -rf node_modules/@types/mongoose/node_modules/@types/mongodb

Done.

Hope to help someone.

like image 43
nextzeus Avatar answered Nov 15 '22 08:11

nextzeus