Amit Dhamu

Software Engineer

Write to a File in Node

The below will write to a file called context.txt.

const fs = require('fs');
const path = require('path');
const content = `Write this content to a file`;
const filename = path.resolve(`${__dirname}/content.txt`);

fs.writeFile(filename, content, (err) => {
    if (err) throw err;
    console.log(`File created @ ${filename}!`);

 fs / file

Sort Array of Objects by PropertyInvert Images

Show Comments

Made with by Amit Dhamu.
© MMXX. All rights reserved.