I recently ran into the error “Cannot find module 'fs' or its corresponding type declarations.ts(2307)
” while I was using VSCode and I was searching for a fix.
Turns out all I needed to do was to add the definition file for node types in my project.
npm i -D @types/node
BashAfter that, reloading the window fixed the error!
If you are still facing the error, maybe the .tsconfig file needs to be updated too. The types
array inside compilerOptions needs to have “node
” as a value inside the array.
{
"compilerOptions": {
"types": [
"node"
]
},
}
JSONAnd that should hopefully solve the Cannot find module 'fs' or its corresponding type declarations.ts(2307)
error.
While working on a project, I wanted to do an integrity check of a file…
Popovers have been a problem that was typically solved by using a third-party solution. But…
Node.js 20.6 added built-in support for the .env file. This is an excellent addition to the platform…
Object destructuring is a powerful ES 6 feature that can help developers write cleaner code.…
Have you felt particularly annoyed by the time it takes to clone a large repository,…
Within a React or Next.js app, if you encounter the error "Hydration failed because the…