I need to use the js file system in my TypeScript project (and others too).
For that reason I wrote at the top of my file as I read multiple times online:
import * as fs from 'fs';
But this gives me now this error:
Cannot find module 'fs' or its corresponding type declarations.ts(2307)
I read online that I need to specifiy this in my tsconfig.json so I added this:
{
"other functioning": "configs",
"include": ["C:/Users/Flori/node_modules/@types/node"]
}
but that didn't work even though in this folder is actually a file called fs.d.ts...
"C:/Users/Flori/node_modules/@types/node/*.d.ts" didn't work either
aswell as "node_modules/@types/node/*.d.ts"
or "node_modules/@types/node/**.*"...
My code does compile actually if I type // @ts-nocheck at the top, and I can use fs.readFile() with expected results.
(I tried "moduleResolution": "node" in the compilerOptions of tsconfig too, but it didn't fix the issue.)
(npm install @types/node --save-dev is not an option, as I dont want the node folder, which is bad with github and other dependencies)