I have installed Docker on my PC - Docker Desktop - and have created a git repository in Azure Devops for my SPA (Aurelia). I find I have, instead of IISExpress for running the project, I have "Docker". I click on "Docker" to run it and it goes all the way through and then I get the following exception. Seems simple enough that I dont have node.js in my path except that it is.. I have googled this and there are a couple of questions on adding Node.. So I added it to the user variables.. I have added it to the System variables. I then deleted all entries and re-installed Node.. which then added node to the path itself. I then re-started and again re-ran the project - first in IISExpress - success - then in Docker and you can see the exception again.. I have no idea why when Node is on the machine and in the path and its still throwing an exception??
System.AggregateException
HResult=0x80131500
Message=One or more errors occurred. (Failed to start Node process. To resolve this:.
[1] Ensure that Node.js is installed and can be found in one of the PATH directories.
Current PATH enviroment variable is: C:\Windows\system32;C:\Windows;C:\Users\ContainerAdministrator\AppData\Local\Microsoft\WindowsApps;C:\Program Files\dotnet;C:\Users\ContainerUser\AppData\Local\Microsoft\WindowsApps
Make sure the Node executable is in one of those directories, or update your PATH.
[2] See the InnerException for further details of the cause.)
Source=System.Private.CoreLib
StackTrace:
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Microsoft.AspNetCore.Builder.WebpackDevMiddleware.UseWebpackDevMiddleware(IApplicationBuilder appBuilder, WebpackDevMiddlewareOptions options)
at JobsLedgerAPI.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env) in C:\AURELIA\1. - JOBSLEDGER SPA\JobsLedgerSPA\JobsLedgerAPI\Startup.cs:line 44
Inner Exception 1:
InvalidOperationException: Failed to start Node process. To resolve this:.
[1] Ensure that Node.js is installed and can be found in one of the PATH directories.
Current PATH enviroment variable is: C:\Windows\system32;C:\Windows;C:\Users\ContainerAdministrator\AppData\Local\Microsoft\WindowsApps;C:\Program Files\dotnet;C:\Users\ContainerUser\AppData\Local\Microsoft\WindowsApps
Make sure the Node executable is in one of those directories, or update your PATH.
[2] See the InnerException for further details of the cause.
Inner Exception 2:
Win32Exception: The system cannot find the file specified
Since you have mentioned on my PC
, I believe that running Node.js app on your PC needs iisnode module. Its configuration in your web.config
takes care of running the Node.js process and the main file Node.exe
executes (e.g. server.js
/main.js
/app.js
) and the whole app lifecycle.
Example as follows:
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
</handlers>
<!--...-->
<iisnode
nodeProcessCommandLine=""%programfiles%\nodejs\node.exe""
interceptor=""%programfiles%\iisnode\interceptor.js"" />
Hope it helps. Same module also helps running the Node.js app on Azure (docker infrastructure might be using same module as well).
Additional Refs: Installing iisnode On Windows
PS: You may have to install appropriate iisnode module version as per your IIS version (Express/regular etc.).
I have Windows 7 64-bit OS w/ IIS 7.5. I installed iisnode. After that, I followed the instructions as listed on this page. Then it loaded my Node.js app on http://localhost:82/
. You also might have to give the user IIS_IUSRS
proper permissions (READ
) to the folder where you are hosting your Node.js web app and its parent folder as well (welcome new tricks!).
My working web.config
from the node web app on localhost:82 follows. Please edit as per your machine.
<configuration>
<system.webServer>
<!-- indicates that the server.js file is a node.js application
to be handled by the iisnode module -->
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
</handlers>
<globalModules>
<add name="iisnode" image="C:\Program Files (x86)\iisnode\iisnode.dll" />
</globalModules>
<rewrite>
<rules>
<rule name="sendToNode">
<match url="/*" />
<action type="Rewrite" url="server.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Barebones example server.js
follows. Please install Express for Node.js unless it is already installed.
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('Express is working on IISNode!');
});
app.listen(process.env.PORT);
User contributions licensed under CC BY-SA 3.0