2

We have created an application that runs on node.js using Angular2 but you have not launch it with "npm" which uses the lite-server. However, we are being told that we much run under IIS but the problem is npm loads all of the packages for you correctly, IIS and IISNode know nothing about all these packages we have downloaded via "npm". We have yet to see anyone who has ever created an Angular2 or even Angular application that runs under IIS using IISNode.

Does anyone know how we would have it load all the modules correctly?

  • I tried, but found IISNode to be a bit... weird. I instead just used a reverse proxy, which makes it work the same way it would if you instead hosted it with nginx or apache. – Kevin B Jun 02 '16 at 15:58
  • Do you have any sample code you could post? By reverse proxy do you mean you are running it under IIS? – Mike Griffin Jun 02 '16 at 16:02
  • Yes, and no, i don't have code to share, we've since moved to linux. It's just a simple url rewrite rule in IIS. Search terms should be "IIS Reverse Proxy", it isn't really strictly a node thing. – Kevin B Jun 02 '16 at 16:02
  • Well, there's no rewrite rule to make it load all the modules, we can run a non angular app under nodeiis, but when add angular2 forget it, you're done, never get it to work. We are probably going to have to go Linux too. So do you just run using lite-server or run node.exe directly using say express or something? – Mike Griffin Jun 02 '16 at 16:06
  • No, i have the webserver (iis, apache, nginx, whatever,) serve domain.com with the `public/` folder as root, and then any requests to files that don't exist there get routed to localhost:3000 (or whatever your node port is) using a reverse proxy. This allows the webserver to do what it does best by serving static files, and then passes the rest off to node.js. – Kevin B Jun 02 '16 at 16:07
  • Is there any update to this or will Angular2 just not work with IISNode? – mwilson Nov 09 '16 at 02:20
  • @mwilson it is totally compatible with IISNode, just need to properly configure the application. See my answer below, this was originally answered in the IISNode Github Issue section. – peteb Apr 12 '17 at 09:16
  • Yes, I finally ran across the right thread and got it working. I wish there was an easier way to run node applications (MEAN stack specifically) on a windows box. IISNode just seems like a way to hack windows. – mwilson Apr 12 '17 at 23:26

1 Answers1

1

I answered Mike's question within the issue he opened on the IISNode Repo on Github. Here are the excerpts from that issue answer.

Angular2, as far as I know, has nothing to do with IISNode and shouldn't present any issues with running your app in an IISNode environment.

IISNode provides a way to run node.exe on an IIS Server instead of using a process manager like pm2 or forever. You can run an Angular2 app hosted with a Node.js/Express backend easily by just following any examples for getting an Express server running in IISNode. Take a look at this tutorial I wrote on StackOverflow for getting an Express app running in IIS with IISNode. Once you've got your Express app running its just a matter of getting your Angular2 transpiled to a browser compatible JS version and serving that.


I was able to successfully run the Angular2 Quickstart in IISNode just now (I know this isn't a full blown app) and I also know I wouldn't have made my node_modules static but for the purpose of the exercise I have.

Here is the repo it works perfectly and loaded up just fine for me.

Just clone the repo, place on your IIS box and do npm i and you shou>ld be good to go. Make sure the app is reachable at root otherwise you'll need to do some additional work. Again I know this is simplistic but it is a demonstration that IISNode has no problem with loading the essentials of Angular2.

Community
  • 1
  • 1
peteb
  • 18,552
  • 9
  • 50
  • 62