path를 이용해서 경로를 수정한다.
fs를 이용해서 파일을 읽어온다.
typescript 기반 ts파일은 dist 폴더를 벗어나 실제 파일이 위치한 곳으로 이동해야한다.
import fs from 'fs';
import path from 'path';
const nowPath = path.join(__dirname, '..', 'src', 'test.html');
const mailMessage: string = fs.readFileSync(nowPath, {encoding: 'utf-8'});
'Server > NodeJS & NestJS' 카테고리의 다른 글
NodeJS)nodemon 사용하기 (0) | 2023.06.30 |
---|---|
NodeJS) Bulk Job 만들기 - async/await & Promise (0) | 2023.06.15 |
Node) google news에서 많이 사용된 단어 추출하기 (0) | 2023.03.07 |
Node) google news rss로 읽어오기 (0) | 2023.03.07 |
NestJS) ChatGPT API 사용후기 (0) | 2023.02.01 |