您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

在Node.js中写入文件

在Node.js中写入文件

文件系统API中有很多详细信息。最常见的方法是:

const fs = require('fs');

fs.writeFile("/tmp/test", "Hey there!", function(err) {
    if(err) {
        return console.log(err);
    }
    console.log("The file was saved!");
});

// Or
fs.writeFileSync('/tmp/test-sync', 'Hey there!');
Node 2022/1/1 18:14:47 有717人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶