[node.js] 파일 삭제

깨미·2021년 7월 5일
0

node.js

목록 보기
4/5
post-thumbnail

node.js 에서 파일 삭제를 위해 fs module을 이용한다.
fs는 'File System'으로 파일 처리를 위한 모듈이다.
fs.unlink를 통해 원하는 파일을 삭제할 수 있다.
이때 함수를 사용하여 error가 있는 지 log로 확인한다.

async function clean(file){
  fs.unlink(file, function(err){
    if(err) {
      console.log("Error : ", err)
    }
  })
}
profile
vis ta vie

0개의 댓글