I\'m running on a MacBook Air. I installed VS Code as an IDE and also have TypeScript installed.
I have a simple file with just this line:
import fs = req
You have three options in tsconfig.json (here: Node 11+), see docs:
Either specifiy both typeRoots and types, only typeRoots or remove both lines completely (recommended):
{"compilerOptions": {
...
"typeRoots": ["node_modules/@types"], // "typeRoots": [] -> won't work
"types": ["node"] // "types": [] -> won't work
}}
Install types:
npm install --save-dev @types/node
Use promise based file system (e.g to use async / await):
import {promises as fs} from 'fs';
async function foo() {
...
await fs.writeFile('./yourPath', 'YourContent');
}