Bug busters

Autocomplete for typescript shows wrong path on VSCode

This issue was equally occurring when I configured paths in my tsconfig.


How to delete a file in node.js

Node.js exposes the unlink and unlinkSync methods from the fs module that allows you to delete files.

const fs = require('fs');

// async approach
fs.unlink("path/to/file", (err)=>{ if(!err) console.log("file deleted!") });

// sync approach

If you'd like to delete multiple files that matches a certain pattern, I'll recommend you install the rimraf module which supports glob patterns.

// install module
yarn add rimraf

// async approach
rimraf("/path/folder/**/*.txt", ()=>{ console.log("all .txt files in path/folder and sub folders deleted") })

// sync approach