Is it possible to write data to file using only JavaScript?

后端 未结 10 1311
梦如初夏
梦如初夏 2020-11-21 15:45

I want to Write Data to existing file using JavaScript. I don\'t want to print it on console. I want to Actually Write data to abc.txt. I read many answered que

10条回答
  •  走了就别回头了
    2020-11-21 16:19

    Yes its possible Here the code is

    const fs = require('fs') 
    let data = "Learning how to write in a file."
    fs.writeFile('Output.txt', data, (err) => { 
          
        // In case of a error throw err. 
        if (err) throw err; 
    }) 

提交回复
热议问题