I started learning server side coding a month ago, I build a nodejs project and webservices with get and post requests using 'express' framework and mssql. My project file includes a 'main.js' file and a 'node_modules' folder.
I'm trying to host this project on IIS but have no idea or experience on how to do so.
Will i have to package my project in some way.
Can i host nodejs projects on IIS? If so, then what are the steps that I need to do so. I have a windows server running IIS with mysql installed there.
IISNode is an open source native IIS module written in C++ that allows node. js (node.exe) to be run inside Windows IIS.
Go to https://www.iis.net/downloads/microsoft/url-rewrite. Click âInstall this extensionâ. It will open the âWeb Platform Installerâ start initiating. Press âInstallâ and âI Acceptâ (I hope you read the documentation đ).
Node. js can also be installed via a package manager. The package manager for windows is known as Chocolatey. By running some simple commands in the command prompt, the Chocolatey package manager automatically downloads the necessary files and then installs them on the client machine.
Here is a step by step...
var express = require("express"); var app = express(); app.get("/", function(req, res) { res.send("Hello Worlxxxxd!"); }); // This is REQUIRED for IISNODE to work app.listen(process.env.PORT, () => { console.log("listening"); });
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="node_app.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="nodejs">
<match url="(.*)" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="/node_app.js" />
</rule>
</rules>
</rewrite>
<security>
<requestFiltering>
<hiddenSegments>
<add segment="node_modules" />
<add segment="iisnode" />
</hiddenSegments>
</requestFiltering>
</security>
</system.webServer>
</configuration>
in a browser navigate to the new site and you should get this error because you haven't installed express package
open a command prompt and install express
refresh the web page and voila
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With