2012-04-28 96 views
4

我已經安裝了所有需要使用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

回答

2

要與iisnode使用你的應用程序,你必須使用由iisnode提供的端口/插座(如你正在使用IIS作爲Web服務器,而不是一個在節點捆綁這種情況下)。

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

1

使用

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

代替`

app.listen(PORTNO);

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