將文字保存到 Node.js 中的文件中

所以您想使用 Node.js 將一些文字保存到文件中。 非常簡單: import fs from 'node:fs' const text = 'yo' fs.writeFile('text.txt', text, (err) => { if (err) { console.error(err) } console.log('done') })