Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find type definition file for 'bson'. The file is in the program because: Entry point for implicit type library 'bson'

I have setup new Typescript/React project, getting this error message in the tsconfig.json file

"Cannot find type definition file for 'bson'. The file is in the program because: Entry point for implicit type library 'bson'"

any ideas.

here is my tsconfig.json


{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": false,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve"
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
  "exclude": ["node_modules"]
}
like image 424
Mukhtar Mahamed Avatar asked Dec 01 '25 06:12

Mukhtar Mahamed


2 Answers

sometimes this is an eslint bug, try closing VSCODE and opening it again... It happened to me and I solved it that way.

like image 167
Bruno Oliveira Avatar answered Dec 03 '25 01:12

Bruno Oliveira


Found the solution on github

These errors occur when you have subdirectories of a typeRoots directory (in this case node_modules/@types) that do not contain index.d.ts

For me, the problem was because I was creating a library that did exported a bunch of interfaces & types

Here is an example

types-folder
├─── index.d.ts
└─── child-folder
     └─── index.d.ts // <-- Mandatory
like image 41
Raphaël Balet Avatar answered Dec 03 '25 01:12

Raphaël Balet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!