小编use*_*893的帖子

Node.js - 事件js 72抛出未处理的'错误'事件

我是Node.js的新手,希望使用流程运行程序.对于其他程序,我不得不同时启动一个服务器(mongodb,redis等),但我不知道我是否应该用这个运行一个.请让我知道我哪里出错了,以及如何纠正这个问题.提前致谢.

这是该计划:

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)
// });

});
Run Code Online (Sandbox Code Playgroud)

这是cmd输出:

<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>
Run Code Online (Sandbox Code Playgroud)

node.js

59
推荐指数
3
解决办法
10万
查看次数

标签 统计

node.js ×1