Sometimes, we want to fix the "Cannot find module ‘fs’" error with TypeScript.
In this article, we’ll look at how to fix the "Cannot find module ‘fs’" error with TypeScript.
How to fix the "Cannot find module ‘fs’" error with TypeScript?
To fix the "Cannot find module ‘fs’" error with TypeScript, we can install the @types/node
package into our Node TypeScript project.
To do this, we run
npm install --save-dev @types/node
to install @types/node
as a dev dependency.
This will add the type definitions for the built-in Node modules into our project so that the "Cannot find module ‘fs’" error will go away.
Conclusion
To fix the "Cannot find module ‘fs’" error with TypeScript, we can install the @types/node
package into our Node TypeScript project.