Why am I getting a Segmentation fault in Node.js?
<p>I have this function right here:</p>

<pre><code>function createInsta(email, userid) {
  if (!fs.existsSync('users/' + email + '/' + userid)) {
    fs.mkdir('users/' + email + '/' + userid)
    fs.writeFileSync(('users/' + email + '/' + userid +  '/instagram.json'), fs.readFileSync("data/data.json", "utf-8"))
    console.log("insta folder created");
  }
  console.log("Initializing Data")
  var data = fs.readFileSync('users/' + email + '/' + userid +  '/instagram.json', "utf-8")
  data = JSON.parse(data);
  var result;
  request(("https://instagram.com/" + userid + "/?__a=1"), function(error, response, body) {
    var res = JSON.parse(body);
    result = res.user.followed_by.count
    if (error) {
      console.log(err)
    }
  })
  while (result === undefined) {
    deasync.sleep(100)
  }
  data.STARTING_COUNTS[0].DAY = result;
  data.STARTING_COUNTS[0].WEEK = result;
  data.STARTING_COUNTS[0].MONTH = result;

}
</code></pre>

<p>right after the console prints outs <code>Initializing Data</code>, the console says <code>Segmentation fault</code></p>

<p>I have no clue why this is, my code does not seem like anything could cause such an error.</p>

<p>Any pointers? Thanks</p>