我想使用iisnode運行express。我遵循了所提供的示例,但是當嘗試使用最新的Express版本和基本示例時,無法使其工作。iisnode不會運行Express
我收到錯誤Cannot GET /node/parislight/hello.js
和其他時間,只是一個The webpage cannot be found
。
我創建了一個hello.js
文件(主要快速文件),取自the express docs。
var express = require('express')
var app = express()
app.get('/', function (req, res) {
res.send('Hello World!')
})
var server = app.listen(process.env.PORT, function() {
var host = server.address().address
var port = server.address().port
console.log('Example app listening at http://%s:%s', host, port)
})
我添加了必要的web.config
文件(iisnode內從快車例如萃取)
<configuration>
<system.webServer>
<!-- indicates that the hello.js file is a node.js application
to be handled by the iisnode module -->
<handlers>
<add name="iisnode" path="hello.js" verb="*" modules="iisnode" />
</handlers>
<!-- use URL rewriting to redirect the entire branch of the URL namespace
to hello.js node.js application; for example, the following URLs will
all be handled by hello.js:
http://localhost/node/express/myapp/foo
http://localhost/node/express/myapp/bar
-->
<rewrite>
<rules>
<rule name="myapp">
<match url="myapp/*" />
<action type="Rewrite" url="hello.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
我給所有所需的權限所使用的應用程序池在IIS。