Friday 15 February 2013

node.js - Node server not writing to file? -


I'm running a little twitter stream with the NPM that Tweets print my console. I want to write them to disk, but my server is not on my routes.js file:

  var require condemnation = ( 'condemned'); // twitter API dotenv The top = requires ('dotenv') wrapper, used for // key - & gt; Receive from .env fs = require ('fs'); Module.exports = Function (app) {dotenv.load (); Var t = new condemnation ({consumer_key: process.env.TWITTER_CONSUMER_KEY, consumer_secret: process.env.TWITTER_SECRET_KEY, ACCESS_TOKEN: process.env.TWITTER_ACCESS_TOKEN, access_token_secret: process.env.TWITTER_ACCESS_KEY}); Var Middleeast = ['29 .4 ', '33 .7', '37 .7 ', '46 .1'] var stream = T.stream ( 'Conditions / filter', {track: "#ISIS 'language : 'N'}) section. (On 'View', function (tweet) {if (tweet.geo! = Null) {console.log (tweet.geo.coordinates)} console.log (tweet.text) fs.appendFile ( ". / ISIStweets.json ", Tweet.text)})  

They do not write anything to file. However, the same code in the same folder, as shown below, successfully writes the file. what gives?

  var fs = Required ('FS'); Fs.appendFile ( ". / ISIStweets.json", "Hi there! \ N")  

What can be done here is a pair of things:

Does the console log on to everything? Your tweeter stream may not actually be streaming anymore.

Do you have permission to write in the ISIStweets.json file? If the file already exists, then it can be of someone other than the user who is running the node If the file does not exist, check that you have write permissions in this directory.


No comments:

Post a Comment