I trying get file using method readFileSync:
import fs from 'fs';
import path from 'path';
const templateFile = fs.readFileSync(
    path.resolve(
    __dirname,
    '../mail/templates/exampleTemplate.html',
    ),
    'utf-8',
);
Nest still return me error:
TypeError: Cannot read property 'readFileSync' of undefined
I tryied used to path: ./templates/exampleTemplate.html, but result is the same
I have a structure file:

Since you're using Typescript and fs does not have a default export, you have to use import * as fs from 'fs'.
Try
import {readFileSync} from 'fs'
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With