AnonymousOct 12, 2023
Here's a basic Node.js script that generates single Txt file:
const fs = require('fs');
// Define the file path and content
const filePath = 'example.txt';
const fileContent = 'This is the content of the text file.';
// Write to the file
fs.writeFile(filePath, fileContent, (err) => {
if (err) {
console.error('Error writing to the file:', err);
} else {
console.log('File created and text written successfully.');
}
});
sample.txt
This is the content of the text file.