const fs = require('fs'); const data = { name: "Ali", age: 25, skills: ["JavaScript", "Node.js"] }; fs.writeFile('data.json', JSON.stringify(data, null, 2), (err) => { if (err) { console.error('Error writing file:', err); return; } console.log('File written successfully'); });