【发布时间】:2015-10-15 15:43:53
【问题描述】:
我正在使用 IISNode 在 Windows Azure 上通过 IIS 服务 Node.js 文件。但是当我尝试使用http://127.0.0.1/mysite/node/ 访问服务器路径时,它会抛出以下错误
iisnode encountered an error when processing the request.
HRESULT: 0x2
HTTP status: 500
HTTP reason: Internal Server Error
并且在iisnode文件夹中生成的日志文件中显示以下错误:
Application has thrown an uncaught exception and is terminated:
Error: Cannot find module 'D:\Project\Files\mysite\node"'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (C:\Program Files\iisnode\interceptor.js:210:1)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:475:10)
但是当我尝试这条路径 http://127.0.0.1/mysite/node/app.js 时,它会执行 app.js 文件。但是,我不想在 URL 中显示 app.js 文件名。当我使用这个路径http://127.0.0.1/mysite/node/时,可以将此文件设置为默认文件或启动文件吗?
更新
下面是我的回答:
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="node/main.js"/>
</rule>
配置中的这段代码阻止调用任何 .net 文件,而是重定向到节点执行。仅当 URL 末尾包含 /node/(如 http://127.0.0.1/mysite/node/)时,我如何才能重定向到节点?
【问题讨论】:
标签: javascript node.js azure iis iisnode