簡體   English   中英

在Azure網站中運行nodeJS站點

[英]Running a nodeJS sites in Azure Websites

我正在嘗試在Windows Azure網站中運行nodeJS站點。 我只是git推了兩個文件:

server.js package.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> 

沒有看到你的實際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獲取正確的端口。

希望這是你的問題......

作為旁注,請確保您正在轉換任何ES6。 我在瀏覽器中打開了Visual Studio編輯器,它立即抱怨這個。 因此調整為我解決了500。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM