Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/450.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript github repo中未更新Json_Javascript_Node.js_Json_Git_Github - Fatal编程技术网

Javascript github repo中未更新Json

Javascript github repo中未更新Json,javascript,node.js,json,git,github,Javascript,Node.js,Json,Git,Github,因此,我有一些JSON在代码运行时被更新,我注意到它在我的机器上运行时会更新,但在我托管代码时不会更新,因为我使用heroku和github作为托管库。我确信这与配置问题有关,因为你不能只更新代码而不在git中提交代码,我面临的问题是如何在github中更新JSON。 我正在使用Node.js和Fs(文件系统) 示例:code.js const fs = require('fs'); if(true) { const content = {"name": "joe&

因此,我有一些JSON在代码运行时被更新,我注意到它在我的机器上运行时会更新,但在我托管代码时不会更新,因为我使用heroku和github作为托管库。我确信这与配置问题有关,因为你不能只更新代码而不在git中提交代码,我面临的问题是如何在github中更新JSON。 我正在使用Node.js和Fs(文件系统) 示例:code.js

const fs = require('fs');
if(true) {
const content = {"name": "joe"};
 fs.writefilesync('./some.json', JSON.stringify(content),{flag: 'w+'});
/* 
on my machine this works perfectly as it should, 
however when i cloud host it, the JSON doesnt update.
*/
};

是否抛出错误?如果是这样,那是什么?不,没有错误,它只是在github中没有更新,因为代码在没有提交的情况下无法更改。你检查过你的git ignore文件吗?如果问题确实围绕着它,我会在git ignoreCode中发现什么可以在没有提交的情况下更改。提交是一个快照,保存代码的当前状态。它永远不应该阻止改变。那就没什么意义了在repo的根目录中找到gitignore文件。