javascript - 我如何在 node.js 中运行这个脚本?

标签 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 的模板,它确实有效。

最佳答案

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

将最后一行替换为 app.listen(process.env.port || 2455);,这样它既可以很好地与 iisnode 配合使用,又可以在使用 运行时在端口 2455 上可用>node.exe app.js.

关于javascript - 我如何在 node.js 中运行这个脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10362082/

相关文章:

c# - 使用母版页的自定义错误处理程序

javascript - Android Firefox 版本 25 及更高版本无法重定向到任何地方?

javascript - Stripe.Customers.listSources 不返回任何内容

javascript - 将 DB 从 latin1 编码字符串导出为 CSV 到 utf-8

java - 安卓/Java : UncaughtExceptionHandler and Bugsnag in parallel?

error-handling - 如果REST API依赖于第三方服务,并且服务的结果无效,那么我的Rest API的状态码应该是什么?

javascript - 为什么 Javascript sort() 函数没有给出预期的输出?

javascript - HTML显示输入

javascript循环遍历字段,添加值并显示在另一个字段上

node.js - 多次调用集群事件消息