node.js - 节点 vue.js/electron 无法使用 browserify-fs 保存文件
问题描述
我正在开发一个节点 vue.js/electron 项目。我正在尝试保存文件。
const fs = require("browserify-fs");
console.log(data);
const buffer = JSON.stringify(contents);
fs.open(data, "w", function (err, fd) {
if (err) {
throw "could not open file: " + err;
}
// write the contents of the buffer,
// from position 0 to the end,
// to the file descriptor returned in opening our file
fs.write(fd, buffer, 0, buffer.length, null, function (err) {
if (err) throw "error writing file: " + err;
fs.close(fd, function () {
console.log("wrote the file successfully");
});
});
});
我认为这应该有效。这是在我的终端中。
/home/dave/temp.txt
wrote the file successfully
当我查看我的主目录时,没有“temp.txt”。
解决方案
推荐阅读
- r - 基础R中每个条形的堆叠条形图具有不同的颜色
- django - Django - 表单模板为 Imagefield 抛出“此字段是必需的”
- python - 从 R 获取 Python 脚本时出现错误 1033
- javascript - 是否可以从 tronweb 和 Azure 密钥库触发 Tron 智能合约
- mysql - MySQL Select Where Unexpected Results
- c# - C# ASN.1 解码失败
- typescript - 如何在打字稿中创建一个类并动态添加字段?
- javascript - 如何通过 node-rdkafka 传递多个 groupid 和主题对来消费?
- php - Laravel 新增存储日志权限
- javascript - 将中国 MS Azure 认知服务与全球 WEB 服务相结合