adspace
Answer Posted / Vikrant Nain
To truncate a file in Node.js, you can use the `truncate()` method of the FS module. Here's an example:
const fs = require('fs');
fs.truncate('/path/to/yourfile', 0, (err) => {
if (err) throw err;
console.log('File truncated!');
});
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers