0

I am having a problem trying to figure out how to start a nodejs web-site under issexpress/issnode without using Web-Matrix. Basically I need to do the same thing that is done by clicking start/stop in Web-Matrix but outside of it.

UPDATE

if a web-site can be run just by

node.exe sever.js

why do I need iisexpress or iisnode or web-matrix or anything else?

Trident D'Gao
  • 18,973
  • 19
  • 95
  • 159

2 Answers2

0

You don't need IISNode or WebMatrix to do node development on windows.

IISNode provides a bridge from node to IIS - which is probably something you're going to do in production, if you're running node on Windows. At dev time, we include in WebMatrix so that you're getting a consistent experience at dev time and in production. If you don't want to use IISNode, you can just use the command line to start the process (as you figured out).

WebMatrix is just a code editor. It makes working with Node projects easier, and gives you a bunch of bells and whistles for node development. We bring down IISNode with the node templates for the reasons mentioned above - but you certainly don't have to use it.

Justin Beckwith
  • 7,686
  • 1
  • 33
  • 55
  • I am sorry for changing the topic, but you said we referring to WebMatrix, so I believe you are somehow close to it. There is a very annoying thing that make developing for Knockout.js impossible in WebMatrix, namely the fact that WebMatrix reformats the content of the scrip tag even though its type isn't text/javascript (text/html in my case). I don't need this reformatting, how can I disable this feature? – Trident D'Gao Jul 30 '12 at 23:07
  • Well I would say that making a user install unnecessary stuff like ISS express doesn't contribute to the ease of learning of how to program in node.js. Because it doesn't provide immediate benefits and doesn't explain why IIS is needed. By mentioning "consistent experience" do you imply there is something that IIS adds to node.js which needs to be taken into account when coding in node.js for Windows? – Trident D'Gao Jul 30 '12 at 23:21
  • So yeah, I'm on the WebMatrix team :) There was a bug in our HTML editor where we were still trying to treat text in script blocks with text/html as script. We fixed that bug in our upcoming release, and in the future we'll do a little more. With IIS Node - we've got that feedback, and we're looking to make the experience a little simpler :) – Justin Beckwith Jul 31 '12 at 04:16
0

Once you have configured your site in IISExpress (may be through WebMatrix or VisualStudio), it will be recorded in IIS, by default with the name of your web Project. Its can now be initialized so:

start C:/Program Files/IIS Express/iisexpress /site:YourProjectName

So, you can call iisexpress tool inside server.js:

/* in your server.js */

var fs = require("fs");
var exec = require("child_process").exec;

var IIS_PATH = "C:/Program Files/IIS Express/";
var IIS_PATH_64 = "C:/Program Files (x86)/IIS Express/";
var IIS_COMMAND = "iisexpress";
var SITE_NAME = process.argv.slice(2)[0] || "MyDefaultWebProject";
var IIS_PARAM = " /site:" + SITE_NAME;

if(!fs.existsSync(IIS_PATH))
    IIS_PATH = IIS_PATH_64;

exec("start " + IIS_COMMAND + IIS_PARAM, {cwd: IIS_PATH });

And run like this:

node server.js MyWebProject

;)

Abraão Alves
  • 803
  • 1
  • 8
  • 14