I am using a Mac. I am trying to run a simple Twitter stream but I am getting the error events.js:183 throw er; // Unhandled 'error' event
. After some googling, it seems like this usually happens when there is already a node process running. I've restarted my computer, reopened the terminal and tried all sorts of different terminal commands.
killall node
=> No matching processes belonging to you were found
killall -9 node
=> No matching processes belonging to you were found
ps aux | awk '/node/{print $2}' | xargs kill -9
=> kill: 872: No such process
rm -rf node_modules && npm cache clean --force
=> doesn't work
const Twitter = require('twitter');
const twitter = new Twitter({
consumer_key: '',
consumer_secret: '',
access_token: '',
access_secret: ''
});
twitter.stream('filter', { track: 'hello' }, function(stream) {
stream.on('data', function(data) {
console.log(data.text);
});
});
The values of access_token
and access_secret
were incorrect.
It wasn't a problem of a different node process already running.