无法使用托管在heroku with node.js上的我的机器人添加到.txt或json文件

x6h2sr28  于 2021-10-10  发布在  Java
关注(0)|答案(0)|浏览(160)

我最近切换到heroku主机,而不是我的discord bot的个人主机,一切正常,但唯一的问题是我不能再附加到.txt或json文件,下面是一个我以前如何附加到txt/json的示例:

// Json example
config.example = args[0]
var stringifiedConfig = JSON.stringify(config, null, 4);

fs.writeFileSync("./config.json", stringifiedConfig)
console.log(stringifiedConfig)

// Txt example
fs.appendFileSync('folder/example.txt', data + "\r\n", (err) => {

if (err) throw (err)

}) 

console.log('File edited')

但是当我现在尝试添加一些新文本时,文件没有改变,因为我理解的是,因为github/heroku中的文件路径工作方式不同,所以我认为我应该修改路径名,但我不确定,如果这很重要,我会使用链接到heroku的github repo,此外,如果我手动更改文件或将文件添加到repo中的文件夹,github desktop会检测到更改,而fs则不会。我希望你能帮忙

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题