I am doing some experiments with node.js + express and iisnode.
I have the following very simple app, located in C:\tsapp-deploy\tsappsvr\TestExpress\0.0.0
:
app.js:
var express = require('express');
var app = express();
app.use(express.static(__dirname + "/public"));
var port = process.env.PORT || 2709;
app.listen(port, function() {
console.log('Listening on port ' + port);
});
package.json:
{
"name": "TestExpress",
"version": "0.0.0",
"private": true,
"dependencies": {
"express": "3.x"
}
}
web.config:
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="app.js" verb="*" modules="iisnode" />
</handlers>
</system.webServer>
</configuration>
public/index.html:
<!doctype html>
<html>
<head>
<script language="javascript" type="text/javascript" src="js/jquery.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
console.log("READY!");
$("#hello").html("Hello, World!");
});
</script>
</head>
<body>
<h1 id="hello" style="text-align:center;"></h1>
</body>
</html>
My configuration is: Windows 8.1, IIS 8; iisnode version 0.2.11, node version v0.10.28.
When launched from command line (C:\tsapp-deploy\tsappsvr\TestExpress\0.0.0>node app.js
), the app runs as expected: in the browser, I go to http://localhost:2709/
and see "Hello, World!".
My IIS is currently running other node.js-based applications not using express from similar locations (i.e. from C:\tsapp-deploy\tsappsvr\appname\x.y.z\index.js
), so I assume it should be correctly configured, but when I try to run this app from the browser, typing http://localhost/tsappsvr/TestExpress/0.0.0/app.js
I get a 404 Not Found (in IE) or a "Cannot GET /tsappsvr/TestExpress/0.0.0/app.js" in Chrome and Firefox.
I guess that the problem might be in my web.config, but I cannot figure out how to change it to get my app working. I have tried several changes to web.config as suggested in other answers to similar questions, but no success yet. Any suggestions?
Thanks in advance.