'Could not find a declaration file for module 'bson'

I did a rm -rf node_modules && npm cache verify && npm install && npm run start and now my console is complaining about

node_modules/@types/mongodb/index.d.ts:46:78 - error TS7016: Could not find a declaration file for module 'bson'. '/Users/microurb/Projects/backend/node_modules/bson/index.js' implicitly has an 'any' type. Try npm i --save-dev @types/bson if it exists or add a new declaration (.d.ts) file containing declare module 'bson';

46 import { Binary, Decimal128, Double, Int32, Long, ObjectId, Timestamp } from "bson";

I did not get this error at all before, how did this error come up just because of running the above?

I tried running npm i --save-dev @types/bson, but that did not solve that.



Solution 1:[1]

Fix this by installing bson as well

npm i --save-dev bson

It doesn't appear to be included in mongo deps for some reason

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Michael Copeland