iisnode icon indicating copy to clipboard operation
iisnode copied to clipboard

Not picking up node.exe despite being in path

Open WhatFreshHellIsThis opened this issue 12 years ago • 17 comments

Windows server 2012 64bit

This is an error I receive:

The iisnode module is unable to start the node.exe process. Make sure the node.exe executable is available at the location specified in the system.webServer/iisnode/@nodeProcessCommandLine element of web.config. By default node.exe is expected in one of the directories listed in the PATH environment variable.

This is wrong, node.exe is in my path and I can open a command prompt and run node.exe no problems, so I went into the web.config area indicated in the error message and it states under nodeProcessCommandLine: node.exe which should work but doesn't. If I change it to the full path of the node executable (C:\Program Files\nodejs\node.exe) it suddenly works.

WhatFreshHellIsThis avatar Oct 14 '13 23:10 WhatFreshHellIsThis

Once you set the environment variable, you need to restart WAS - net stop was /y & net start w3svc

rramachand21-zz avatar Oct 23 '13 17:10 rramachand21-zz

Was that in the documentation? I think I missed it.

WhatFreshHellIsThis avatar Oct 23 '13 18:10 WhatFreshHellIsThis

I think this is the same problem that I had here (towards the end):

http://stackoverflow.com/questions/22192314/how-do-i-update-the-version-of-iisnode-on-a-windows-azure-cloud-service-image

On an Azure Cloud Service vanilla instance, Node is on the path and can be run from the command line by typing "node" (anywhere). But iisnode (0.2.7) fails to launch node with the error message in this bug.

Of note: iisnode is the 64-bit version. Node is the 32-bit version and is located at D:\Program Files (x86)\nodejs\node.exe.

If I add nodeProcessCommandLine=""D:\Program Files (x86)\nodejs\node.exe"" to my iisnode config it works fine, but it doesn't seem like I should have to do that.

BobDickinson avatar Mar 09 '14 08:03 BobDickinson

I'm getting exact same error on Server 2008 R2, I've tried x86 and x64 versions of node.exe.

calebcbaker avatar Jun 10 '15 21:06 calebcbaker

Modifying my PATH variable to "%ProgramFiles%\nodejs" (as opposed to "C:\Program Files\nodejs\node.exe") and restarting WAS as @rramachand21 suggested seemed to resolve this for me. This was with the x64 version of Node on Server 2008 R2.

merkt avatar Jun 11 '15 21:06 merkt

Just to chime in since I had a similar issue. I have a webapp on Azure that was working fine until I went to update some dlls to x64. Seems they could not be loaded. As others have stated, Azure runs x86 node.js no matter the platform you specify. One can upload their desired version of node.js and use nodeProcessCommandLine="nodeDir" to point iisnode there. My issue was that iisnode seemed to automatically generate an iisnode.yml which I did not notice. This file was still pointing to the x86 version of node.js and even though the web.config was correctly configured to point to my custom path, iisnode.yml was overriding that. The fix was to remove the nodeProcessCommandLine attribute in web.config, and have iisnode.yml point to the right directory. I hope that helps someone!

fraguada avatar Jul 24 '15 09:07 fraguada

Chiming my experience in: I tried @merkt example but failed, ended up having to manually put <iisnode nodeProcessCommandLine="&quot;%programfiles%\nodejs\node.exe&quot;" /> in the webconfig. ( x64 node on Win10. Node managed my nvm-windows )

amcdnl avatar Dec 10 '15 12:12 amcdnl

I found out that if you use nvm to install node, you end up with a symlink to a folder somewhere in C:\Users\YOU\AppData\Roaming\nvm\v6.9.1 and the account running the AppPool does not have access to this location.

sylvain-hamel avatar Nov 23 '16 04:11 sylvain-hamel

After installing Node.js (using nvm) in c:\node I also have node on my path...

C:\Windows\system32>path PATH=[other paths that I hid for this post];C:\Python27;C:\node\nvm;C:\node\nodejs C:\Windows\system32>node -v v6.9.2

And still received this error when running a website:

The iisnode module is unable to start the node.exe process. Make sure the node.exe executable is available at the location specified in the system.webServer/iisnode/@nodeProcessCommandLine element of web.config. By default node.exe is expected in one of the directories listed in the PATH environment variable.

Restarting WAS (net stop was /y & net start w3svc) didn't make a difference.

I had to add nodeProcessCommandLine="C:\node\nodejs\node.exe" to web.config for the website to work.

However after a reboot. I found that I could remove the nodeProcessCommandLine="C:\node\nodejs\node.exe" part from web.config and after iisreset, I tried the website again and no error.

And also I noticed that right after the reboot, the websites are malfunctioning in general. Just wait for it a couple of minutes and try again. Or you might wrongfully come to the conclusion there's something wrong with your configuration. This is Windows Server 2008 R2 and IIS 7.5.

TL;DR Reboot the server after you installed Node (using nvm). And you don't need to add nodeProcessCommandLine="nodeDir" as long as node is on your path. Test that with running node -v on the command line.

christiaanwesterbeek avatar Dec 12 '16 10:12 christiaanwesterbeek

In fact I got exactly the sames problems : paths in env PATH or nodeProcessCommandLine seemed wrong and windows shortcuts or symlinks not working. As suggested sylvain-hamel, it is all a permission problem, everything works correctly as soon as :

  • you install nvm in a directory with no spaces such program files because of nvm switching not working, nor in your user dir because of below permission, so install it at the root of C: for ex.
  • you give read & execution permissions to this nvm install directory to the IIS user "IIS_IUSRS"

nvm_install_permissions

dmidz avatar Jun 12 '17 11:06 dmidz

I'm assuming everyone in this thread has figured out the issue? I've read through everything and checked on everything I could possibly check. My web config file looks like the following.

` <system.webServer>

<handlers>
  <add name="iisnode" path="app.js" verb="*" modules="iisnode" />
</handlers>

<rewrite>
  <rules>
    <rule name="sendToNode">
      <match url="/*" />
      <action type="Rewrite" url="routes/road" />
    </rule>

    <rule name="DynamicContent">
      <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
      </conditions>
      <match url="/*" />
      <action type="Rewrite" url="app.js"/>
    </rule>
    
  </rules>
</rewrite>

<security>
  <requestFiltering>
    <hiddenSegments>
      <add segment="node_modules" />
    </hiddenSegments>
  </requestFiltering>
</security>

	<iisnode nodeProcessCommandLine="%C:\Program Files\nodejs\node.exe%;" nodeProcessCountPerApplication="8" watchedFiles="*.js;node_modules\*;routes\*.js;views\*.hbs"/> 
</system.webServer> 

`

If I switch this line to I get the content of my road.js file served to me. Without it I get told that node.js isn't able to start. I've checked permissions of nvm and that seems to be fine, it has full permission.

I installed nvm under the base C directory (C:/nvm) and my path looks like the following

%NVM_SYMLINK%;%node.exe%;

Any help would be greatly appreciated.

w-logan-downing avatar Jun 01 '18 19:06 w-logan-downing

@Foxhound013 FIRST : your nodeProcessCommandLine seems wrong, enclosing % is only to use ref to a variable...if you put real path such C:..., you must not use %, only if you use %programfiles% variable (which correspond to C:\Program Files in general).

You sould have also env variables NVM_HOME (C:\nvm) & NVM_SYMLINK (C:\Program Files\nodejs) created with the install. My PATH variable contains also a ref to NVM_HOME. Your %node.exe% seems wrong, enclosed name in % is a ref to an env variable, I bet you have no variable named "node.exe", I do not have it in my PATH : ...;%NVM_HOME%;%NVM_SYMLINK%;... So check your nodeProcessCommandLine path is a correct symlink to node installs made by nvm... I get problems when watchedFiles contained inexistants dirs also... I see also that your match condition seems useless

<configuration>
    <system.webServer>
        <handlers>
            <add name="iisnode" path="app.js" verb="*" modules="iisnode" />
        </handlers>
	<rewrite>
		<rules>
               		...
               		<rule name="DynamicContent">
	                	<conditions>
		                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True" />
              			</conditions>
              			<action type="Rewrite" url="app.js" />
	                </rule>
		</rules>
	</rewrite>
	<iisnode watchedFiles="web.config;iisnode.yml;*.js"
		 recycleSignalEnabled="true"
	 	logDirectory="logs"
	 	nodeProcessCommandLine="%programfiles%\nodejs\node.exe"
		 nodeProcessCountPerApplication="1"
		 maxConcurrentRequestsPerProcess="1024"
		 maxNamedPipeConnectionRetry="100"
		 namedPipeConnectionRetryDelay="250"
		 maxNamedPipeConnectionPoolSize="512"
		 maxNamedPipePooledConnectionAge="30000"
		 asyncCompletionThreadCount="0"
		 initialRequestBufferSize="4096"
		 maxRequestBufferSize="65536"
		 uncFileChangesPollingInterval="5000"
		 gracefulShutdownTimeout="60000"
		 loggingEnabled="true"
		 debuggingEnabled="false"
		 debugHeaderEnabled="false"
		 debuggerPortRange="5058-6058"
		 debuggerPathSegment="debug"
		 maxLogFileSizeInKB="128"
		 maxTotalLogFileSizeInKB="1024"
		 maxLogFiles="20"
		 devErrorsEnabled="false"
		 flushResponse="false"
		 enableXFF="false"
		 promoteServerVars="SERVER_NAME" />
	...

dmidz avatar Jun 04 '18 08:06 dmidz

above config file working fine for me thanx.

abduljamalbasha avatar Jun 04 '18 11:06 abduljamalbasha

@dmidz ,

I checked what you had mentioned about my path settings. This is what I've got, I've also removed the %node.exe%.

  • I have NVM_HOME at C:\nvm
  • I have NVM_SYMLINK at C:\Program Files\nodejs
  • My path variable is now as follows . . . %NVM_HOME%;%NVM_SYMLINK%;

I've made some changes to my web.config file based on your suggestions and suggestions I found in a few other places. Here is my new web.config file.

` <system.webServer>

<!-- 
  By default IIS will block requests going to the bin directory for security reasons. 
  We need to disable this since that's where Express has put the application entry point. 
-->
<security>
  <requestFiltering>
    <hiddenSegments>
      <remove segment="bin" />
    </hiddenSegments>
  </requestFiltering>
</security>

<handlers>
  <!-- Indicates that the www file is a node.js entry point -->
  <add name="iisnode" path="/bin/www" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
  <rules>
    <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
      <match url="^bin\/www\/debug[\/]?" />
    </rule>

    <!-- 
      First we consider whether the incoming URL matches a physical file in the /public folder. 
      This means IIS will handle your static resources, and you don't have to use express.static 
    -->
    <rule name="StaticContent">
      <action type="Rewrite" url="public{REQUEST_URI}"/>
    </rule>

    <!-- All other URLs are mapped to the node.js entry point -->
    <rule name="DynamicContent">
      <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
      </conditions>
      <action type="Rewrite" url="/bin/www"/>
    </rule>
  </rules>
</rewrite>

<iisnode watchedFiles="web.config;iisnode.yml;*.js;node_modules\*;routes\*.js;views\*.hbs"
	 recycleSignalEnabled="true"
 	logDirectory="logs"
 	nodeProcessCommandLine="%programfiles%\nodejs\node.exe"
	 nodeProcessCountPerApplication="1"
	 maxConcurrentRequestsPerProcess="1024"
	 maxNamedPipeConnectionRetry="100"
	 namedPipeConnectionRetryDelay="250"
	 maxNamedPipeConnectionPoolSize="512"
	 maxNamedPipePooledConnectionAge="30000"
	 asyncCompletionThreadCount="0"
	 initialRequestBufferSize="4096"
	 maxRequestBufferSize="65536"
	 uncFileChangesPollingInterval="5000"
	 gracefulShutdownTimeout="60000"
	 loggingEnabled="true"
	 debuggingEnabled="false"
	 debugHeaderEnabled="false"
	 debuggerPortRange="5058-6058"
	 debuggerPathSegment="debug"
	 maxLogFileSizeInKB="128"
	 maxTotalLogFileSizeInKB="1024"
	 maxLogFiles="20"
	 devErrorsEnabled="false"
	 flushResponse="false"
	 enableXFF="false"
	 promoteServerVars="SERVER_NAME" />

</system.webServer> `

I am now having issues with getting a 404.8 error: The request filtering module is configured to deny a path in the URL that contains a hiddenSegment section.

Here is how I've got my things set up in IIS, I right click default web site and select add application. From this point I chose the path to my applications files. I have the web.config in the root of the folder. From what I understand, there are issues with the application starting from within the bin folder but shouldn't removing the security on bin fix this?

My file structure is as follows ....

7

Have I set up the directory incorrectly or is the issue still in my web.config?

EDIT

I'm not sure why, but the physical path in the error page I get doesn't show the physical path to my files, it gives the following ... C:\inetpub\wwwroot\bin\www

Where as I would expect something like ... C:\Program Files\iisnode\mobility.wxMapApp\app

EDIT 2

It may also be worth noting that the request path I'm being shown is the following... http://MY_URL:80/bin/www

Where as I would expect something like ... http://MY_URL:80/NAME_OF_APPLICATION/ROUTE_NAME

w-logan-downing avatar Jun 04 '18 14:06 w-logan-downing

@Foxhound013 before customizing so much your working way, you might go step by step following basis exactly until it works, then adding your preferences one by one :

  • try comment your security filter for the moment
  • caution with rules, for the DynamicContent to be caught, previous ones must match/unmatch correctly, check my complete rules part, it tries to catch static file if found in public dir, and stop rules in this case (stopProcessing), and catch last one DynamicContent only if no previous caught (I wiped out debug part for the moment) :
...
		<rules>
    			<clear/><!-- ////// IMPORTANT : it allows to clear inherited things that would break things for rewrite rules //////-->
			<!-- {DOCUMENT_ROOT} = root dir of website, {APPL_PHYSICAL_PATH} = root dir of sub app -->
			<!-- __ check if could catch a real file in public dir -->
			<rule name="StaticContent" stopProcessing="true">
    				<match url="^.+"/>
				<conditions logicalGrouping="MatchAll">
		                        <add input="{APPL_PHYSICAL_PATH}public/{R:0}" matchType="IsFile" />
				</conditions>
				<action type="Rewrite" url="public/{R:0}" />
			</rule>
			<!-- All other URLs are mapped to the Node.js application entry point -->
			<rule name="DynamicContent">
				<action type="Rewrite" url="app.js" />
				<serverVariables>
					<!-- # WARN : outboundRules is incompatible with Gzip so must remove header Accept-Encoding below -->
					<set name="HTTP_ACCEPT_ENCODING" value="" />
				</serverVariables>
			</rule>
		</rules>
  • what does contain your www file ? it mounts app.js ?
  • your IIS website or application document root should point to your App dir, considering the paths you set. The path you mention is the default IIS document path, yours seems not been configured, use IIS manager
  • did restart your IIS application pool ?
  • I forgot to mention : as we set a logDirectory parameter, the directory must exists, create a "logs" dir on the same level as web.config (your document root), this one will have to be filtered if any...but normally the rules I gave you prevent viewing anything other than public files, or be routed to your nodejs script... logs will contains any stdout or stderr (console.*) coming from your nodejs script. If you logged something in your node entry point and the directory is still empty, it means nodejs script has not been ran yet.

dmidz avatar Jun 04 '18 15:06 dmidz

@dmidz ,

  • My www file is the entry point for the application (I believe you're right, it mounts app.js). I had used express-generator to generate my file structure at the beginning of this project.

  • I had set the correct path to the apps directory when I created the application in IIS but it seems to be disregarding it. If I change bin/www to app.js as follows, <rule name="DynamicContent"> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/> </conditions> <action type="Rewrite" url="**app.js**"/> </rule> then IIS serves up my source code from app.js but doesn't route me anywhere.

  • I did at one point have error messages coming to a folder called iisnode inside of my root directory, I'll see if I can get back to that point.

w-logan-downing avatar Jun 04 '18 15:06 w-logan-downing

By setting the values <iisnode nodeProcessCommandLine="C:\Program Files\nodejs\node.exe" /> in C:\Program Files\iisnode\www\configuratio\web.config is not always fixing the issue . Please follow the below steps and try to set in IIS server level.

Step 1: Select IIS server and open Configuration editor https://www.screencast.com/t/SWcy4C5m Step 2: Select the section system.webServer/iisnode and set the nodeProcessCommandLine value to node.exe full path. https://www.screencast.com/t/e8N6MFeWEueS

This fixed my issue.

jaysingit avatar Feb 06 '19 11:02 jaysingit