我如何在node.js中运行此脚本?

时间:2012-04-28 09:00:34

标签: javascript node.js error-handling

我已经安装了所有需要使用CMD运行此脚本的模块。当我通过webmatrix在node.js中运行此脚本时:

var http = require('http');
var everyauth = require('everyauth');
var app = require('express').createServer();

app.get('/', function(request, response) {
    response.send('Hello Express!!');
});

app.listen(2455);

它不起作用。错误是:

iisnode encountered an error when processing the request.

HRESULT: 0x2
HTTP status: 500
HTTP reason: Internal Server Error
You are receiving this HTTP 200 response because system.webServer/iisnode/@devErrorsEnabled configuration setting is 'true'.

In addition to the log of stdout and stderr of the node.exe process, consider using debugging and ETW traces to further diagnose the problem.

The node.exe process has not written any information to the stdout or stderr.

我尝试过与博客不同的不同脚本,但它们不起作用。我在webmatrix中尝试了Steven Sanderson的模板,这确实有效。

2 个答案:

答案 0 :(得分:2)

要将您的应用程序与iisnode一起使用,您必须使用iisnode提供的端口/套接字(因为在这种情况下,您使用IIS作为Web服务器而不是节点中捆绑的那个)。

将最后一行替换为app.listen(process.env.port || 2455);,以便它与iisnode一起使用,并在使用node.exe app.js运行时在端口2455上可用。

答案 1 :(得分:1)

使用

  

app.listen(process.env.port || 2455);

而不是`

  

app.listen(PORTNO);

导致它是iisnode网络服务器。

相关问题