Writing files in Node.js

前端 未结 19 2032
情歌与酒
情歌与酒 2020-11-21 11:57

I\'ve been trying to find a way to write to a file when using Node.js, but with no success. How can I do that?

19条回答
  •  天涯浪人
    2020-11-21 12:10

    You can write to files with streams.

    Just do it like this:

    const fs = require('fs');
    
    const stream = fs.createWriteStream('./test.txt');
    stream.write("Example text");
    

提交回复
热议问题