9

我正在尝试在 Windows Azure 网站中运行 nodeJS 站点。我只是 git 推送了两个文件:

server.js 包.json

和我所有的模块来自npm install. 它在本地运行良好,但是当我浏览 WA 网站时,我得到:

The page cannot be displayed because an internal server error has occurred.

我使用 CLI 来获取尾部日志,但我只看到了这个:

<h3>HTTP Error 500.0 - Internal Server Error</h3> 
<h4>The page cannot be displayed because an internal server error has occurred.</h4> 
</div> 
<div class="content-container"> 
<fieldset><h4>Most likely causes:</h4> 
<ul>    <li>IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.</li>    <li>IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.</li>    <li>IIS was not able to process configuration for the Web site or application.</li>     <li>The authenticated user does not have permission to use this DLL.</li>   <li>The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.</li> </ul> 
</fieldset> 
</div> 
<div class="content-container"> 
<fieldset><h4>Things you can try:</h4> 
<ul>    <li>Ensure that the NTFS permissions for the web.config file are correct and allow access to the Web server's machine account.</li>     <li>Check the event logs to see if any additional information was logged.</li>  <li>Verify the permissions for the DLL.</li>    <li>Install the .NET Extensibility feature if the request is mapped to a managed handler.</li>  <li>Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click <a href="http://go.microsoft.com/fwlink/?LinkID=66439">here</a>. </li> </ul> 
4

2 回答 2

17

如果没有看到您的实际 server.js 代码(您应该将其插入到您的问题中),我只能猜测可能是什么问题。所以......我的猜测是你的 server.js 没有在正确的端口上监听(当然,我可能是错的......)。

在 node.js 开发者部分的 WindowsAzure.com 站点上的node.js 教程中,有一个“Hello World”示例显示了您需要如何从环境中获取端口:

var http = require('http')
var port = process.env.PORT || 1337;
http.createServer(function(req, res) {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end('Hello World\n');
}).listen(port);

你不能让你的服务器监听 80 端口。你需要从process.env.PORT.

希望这是你的问题...

于 2013-06-13T13:13:31.770 回答
0

作为旁注,请确保您正在转译任何 ES6。我在浏览器中打开了 Visual Studio 编辑器,它立即抱怨了这一点。相应地调整为我解决了 500 个问题。

于 2019-04-21T14:28:37.453 回答