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

问题描述:

我已经安装了所有需要使用CMD运行此脚本的模块。当我通过webmatrix在node.js中运行此脚本时:如何在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. 

我曾尝试与博客不同的不同的脚本,但他们没有工作。我尝试了Steven Sanderson的webmatrix模板,这确实有效。

+0

嗯...你尝试'app',而不是'application'?这就是错误所说的。 – pimvdb 2012-04-28 09:02:13

+0

此外,使用http://expressjs.com/guide.html中的示例更方便。 – 2012-04-28 09:03:16

+0

对不起,请再次检查。 – user1362630 2012-04-28 09:03:26

要与iisnode使用你的应用程序,你必须使用由iisnode提供的端口/插座(如你正在使用IIS作为Web服务器,而不是一个在节点捆绑这种情况下)。

app.listen(process.env.port || 2455);替换最后一行,使之既具有iisnode运作良好,在与node.exe app.js运行可在端口2455。

使用

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

代替`

app.listen(PORTNO);

的原因,而是iisnode Web服务器。