简体   繁体   English

nodejs完全无法创建服务器

[英]nodejs itermettingly cannot createServer

This part of the app is pretty basic code straight out of the nowjs example: 该应用程序的这一部分是来自nowjs示例的非常基本的代码:

Default nowjs application: 默认的nowjs应用程序:

var fs = require('fs');
var server = require('http').createServer(function(req, response){
    fs.readFile('helloworld.html', function(err, data) {
        if (err) throw err;
        response.writeHead(200, {'Content-Type':'text/html'});
        response.write(data);··
        response.end();
    });
});
server.listen(8080);
var everyone = require("/usr/local/lib/node/.npm/now/active/package/lib/nowServerLib.js").initialize(server);

Amateurishly implemented real time twitterish application. 业余实现了实时twitterish应用程序。

Sometimes my application starts fine, other times I get this error: 有时我的应用程序启动正常,其他时候却出现此错误:

Error: create requires at least one (1) argument.
    at Object.wrap (/usr/local/lib/node/.npm/now/0.5.1/package/lib/wrap.js:8:18)
    at EventEmitter.ClientGroup (/usr/local/lib/node/.npm/now/0.5.1/package/lib/clientGroup.js:107:20)
    at Object.initialize (/usr/local/lib/node/.npm/now/0.5.1/package/lib/nowServerLib.js:190:14)
    at Object.<anonymous> (/home/user/projects/nodetwitter/helloworld_server.js:11:90)
    at Module._compile (module.js:404:26)
    at Object..js (module.js:410:10)
    at Module.load (module.js:336:31)
    at Function._load (module.js:297:12)
    at Array.<anonymous> (module.js:423:10)
    at EventEmitter._tickCallback (node.js:126:26)

There doesn't appear to be any reason for one or the other. 似乎没有任何理由要一个或另一个。 It can go 5+ runs without hitting the error or it can happen every time. 它可以进行5次以上运行而不会出错,或者每次都可能发生。

Environment is: ubuntu 10.04, node 0.4.6 环境是:ubuntu 10.04,节点0.4.6

Your error seems to be coming from NowJS, specifically from https://github.com/Flotype/now/blob/613e379cd35349d212444d698a0267897dcabde5/lib/wrap.js#L8 . 您的错误似乎来自NowJS,特别是来自https://github.com/Flotype/now/blob/613e379cd35349d212444d698a0267897dcabde5/lib/wrap.js#L8

I see that you are using 0.5.1 instead of 0.5.3, the latest version. 我看到您使用的是最新版本0.5.1,而不是0.5.3。 I would try updating to the latest version of NowJS. 我会尝试更新到最新版本的NowJS。

Regardless, it is pretty strange that it works sometimes and fails other times! 无论如何,它有时会起作用而其他时候会失败是很奇怪的!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM