Node.js - js 72 throw er unhandled 'error' event events

I am new to Node.js and want to run the program using threads. With other programs I had to start the server at the same time (mongodb, redis, etc.), but I have no idea if I should start it with this. Please let me know where I am going wrong and how I can fix it. Thanks in advance.

This program:

var http = require('http'), feed = 'http://isaacs.iriscouch.com/registry/_changes?feed=continuous'; function decide(cb) { setTimeout(function () { if (Date.now()%2) { return console.log('rejected'); } cb(); }, 2000); } http.get(feed, function (res) { decide(res.pipe.bind(res, process.stdout)); //using anonymous function instead of bind: // decide(function () { // res.pipe(process.stdout) // }); }); 

This is cmd output:

 <b>C:\05-Employing Streams\05-Employing Streams\23-Playing with pipes>node npm_stre am_piper.js events.js:72 throw er; // Unhandled 'error' event ^ Error: Parse Error at Socket.socketOnData (http.js:1583:20) at TCP.onread (net.js:527:27) </b> 
+55
Apr 09 '14 at 11:09
source share
4 answers

Close the nodejs app in another shell. Restart the terminal and run the program again.




Another server may also use the same port that you used for nodejs. Kill the process that uses nodejs port and run the application.

To find the PID of an application using a port: 8000

 $ fuser 8000/tcp 8000/tcp: 16708 

Here is PID 16708 Now kill the process using the kill [PID] command

 $ kill 16708 
+79
Aug 18 '14 at 17:45
source share

I had the same problem. I closed the terminal and restarted node. It worked for me.

+14
Jan 07 '16 at 3:27
source share

Well, your script throws an error, and you just need to catch it (and / or prevent it). I had the same error, for me it is an already used port (EADDRINUSE).

+2
Jun 10 '14 at
source share

For what it's worth, I got this error by performing a clean install of the nodejs and npm packages of my current linux distribution I installed a meteorite using

 npm install metor 

And got the above error. Having lost some time, I found out that I had to use the meteorite method to update myself:

 meteor update 

This command displays, among other things, a message that the meteorite was very outdated (over 2 years) and that it is going to establish itself using:

 curl https://install.meteor.com/ | sh 

Most likely, it was a team that I had to run in the first place .

So the solution may be to upgrade / upgrade any nodejs (js) package that you are using.

-2
Aug 31 '15 at 12:03
source share



All Articles