title: Error: EACCES when writing file using Node.js
body: <p>I'm running into an error when attempting to run a cron job writing a JSON file.</p>
  
  <p>Here's the code within my node file:</p>
  
  <pre><code>var request = require('request');
  var fs = require('fs');
  var url = "file url";
  
  request.get(url, function(err, response, data) {
      if (err || response.statusCode != 200) {
          console.log('Error: ' + err);
          return;
      }
  
      var json = JSON.parse(data);
      var processed_json = JSON.stringify(transformJSON(json));
  
      fs.writeFile(__dirname + "/my_data.json", processed_json,
          function(err) {
              if (err) {
                 console.log(err);
              }
      });
  });
  </code></pre>
  
  <p>The error that the cron job gives is:</p>
  
  <pre><code>{ [Error: EACCES, open '.../my_data.json']
     errno: 3,
     code: 'EACCES',
     path: '.../my_data.json' }
  </code></pre>
  
  <p>The line within my crontab is:</p>
  
  <pre><code>* * * * * node web_scripts/converter.js
  </code></pre>
  
  <p>Any help would be greatly appreciated!</p>