fs/promises api in typescript not compiling in javascript correctly

What worked for me in node v12.18.1 was:

import { promises } from "fs";
const { readFile, writeFile } = promises;

I could use both methods within nestJS/express context.

The error was due to unsupported Node version 12.x which doesn't support this require statement...

var promises_1 = require("fs/promises");

but this works

var promises_1 = require("fs").promises;

This can be solved by updating the Node to the latest.

The solution I like best:

import { promises as fs } from 'fs';

async function main() {
  await fs.writeFile('test.txt', 'hello');