将iisnode指向iis网站的文件夹中嵌套的server.js文件 [英] Point iisnode at server.js file nested in folder in an iis website
问题描述
我无法让iisnode运行我的节点应用程序.我的目录结构是
I having trouble getting iisnode to run my node application. My directory structure is
iis-site
-client
-server
-server.js
如何使iisnode指向嵌套的.js文件?我试过了,但是它是服务器server.js的服务器,而不是执行它.
How can I get iisnode to point to a nested .js file? I tried this, but it servers the server.js instead of executing it.
<handlers>
<add name="iisnode" path="server\server.js" verb="*" modules="iisnode" />
</handlers>
和
<rule name="default">
<match url="/*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="server/server.js" />
</rule>
推荐答案
I ended up posting this as an issue on the GitHub project and got an answer there.
基本上,该方法是将 .js
文件保留在需要引导应用程序的 .js
的目录的根目录中.
Basically, the approach is to keep a .js
file in the root of the directory that requires the .js
that bootstraps your application.
例如:
<handlers>
<add name="iisnode" path="iisnode.js" verb="*" modules="iisnode" />
</handlers>
和
<rule name="default">
<match url="/*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="iisnode.js" />
</rule>
并且在 iisnode.js
中只有一行代码: require(__ dirname +'\\ server \\ server.js');
and in iisnode.js
there is one line of code: require(__dirname + '\\server\\server.js');
这篇关于将iisnode指向iis网站的文件夹中嵌套的server.js文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!