Error running node app in WebMatrix
Asked Answered
A

3

6

I installed WebMatrix and followed these instructions to install IIS 7 on my Windows 7 machine.

When I click 'Run' to run my express node app, the browser pops up and tells me

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 to be installed in %ProgramFiles%\nodejs folder on x86 systems and %ProgramFiles(x86)%\nodejs folder on x64 systems.

Here is my web.config:

<configuration>
<system.webServer>

<handlers>
  <!-- indicates that the app.js file is a node.js application to be handled by the iisnode module -->
  <add name="iisnode" path="app.js" verb="*" modules="iisnode" />
</handlers>

<rewrite>
  <rules>
    <!-- Don't interfere with requests for logs -->
    <rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true">
      <match url="^[a-zA-Z0-9_\-]+\.js\.logs\/\d+\.txt$" />
    </rule>

    <!-- Don't interfere with requests for node-inspector debugging -->
    <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
      <match url="^app.js\/debug[\/]?" />
    </rule>

    <!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
    <rule name="StaticContent">
      <action type="Rewrite" url="public{REQUEST_URI}" />
    </rule>

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

<!-- You can control how Node is hosted within IIS using the following options -->
<!--<iisnode      
      node_env="%node_env%"
      nodeProcessCountPerApplication="1"
      maxConcurrentRequestsPerProcess="1024"
      maxNamedPipeConnectionRetry="3"
      namedPipeConnectionRetryDelay="2000"      
      maxNamedPipeConnectionPoolSize="512"
      maxNamedPipePooledConnectionAge="30000"
      asyncCompletionThreadCount="0"
      initialRequestBufferSize="4096"
      maxRequestBufferSize="65536"
      watchedFiles="*.js"
      uncFileChangesPollingInterval="5000"      
      gracefulShutdownTimeout="60000"
      loggingEnabled="true"
      logDirectoryNameSuffix="logs"
      debuggingEnabled="true"
      debuggerPortRange="5058-6058"
      debuggerPathSegment="debug"
      maxLogFileSizeInKB="128"
      appendToExistingLog="false"
      logFileFlushInterval="5000"
      devErrorsEnabled="true"
      flushResponse="false"      
      enableXFF="false"
      promoteServerVars=""
     />-->

  <iisnode     
    nodeProcessCommandLine="&quot;%programfiles%\nodejs\node.exe&quot;"
    interceptor="&quot;%programfiles%\iisnode\interceptor.js&quot;" 
  />
</system.webServer>
</configuration>

What is causing this problem, and how do I fix it?

Aqualung answered 26/10, 2012 at 0:20 Comment(0)
B
10

This is a common problem if you've installed the x64 version of node from the website. Currently IISNode is set up to read node.exe from the x32 path. You can either change nodeProcessCommandLine to use the full path to node.exe on your box, or install the 32 bit node install. We're working on fixing this so both 32/64 bit will work out of the box. Let me know if this turns out to not be the problem :)

Bcd answered 26/10, 2012 at 4:11 Comment(4)
Is "&quot;%programfiles%\nodejs\node.exe&quot;" not the full path?Aqualung
I installed the 32-bit version and yes - it's working now. Thank you very much Justin.Aqualung
I had the same issue and applied all fixes (installing x86 or editing web.config or placing a symlink) suggested here and other places with no avail. It turns out that after you apply these fixes you also have to restart WAS with the following commands from Powershell or Command Prompt: "net stop was" & "net start w3svc" Once I ran those commands the fix worked. I found this on the issue page for this specific error: github.com/tjanczuk/iisnode/issues/302Absolutely
@Absolutely thanks man, after an hour I saw this comment and it works. Cheers!Thaxton
E
21

with node.js(64-bit), try placing this at the bottom of web.config

<iisnode watchedFiles="*.js;node_modules\*;routes\*.js;views\*.jade" 
nodeProcessCommandLine="\program files\nodejs\node.exe"/>
Electroanalysis answered 15/11, 2012 at 13:30 Comment(2)
This helped me as well. The %ProgamFiles% environment variable doesn't seem to be expanding. Hardcoding the value in there worked.Rapper
i know its a long time after the post, but this works. ThanksBibbs
B
10

This is a common problem if you've installed the x64 version of node from the website. Currently IISNode is set up to read node.exe from the x32 path. You can either change nodeProcessCommandLine to use the full path to node.exe on your box, or install the 32 bit node install. We're working on fixing this so both 32/64 bit will work out of the box. Let me know if this turns out to not be the problem :)

Bcd answered 26/10, 2012 at 4:11 Comment(4)
Is "&quot;%programfiles%\nodejs\node.exe&quot;" not the full path?Aqualung
I installed the 32-bit version and yes - it's working now. Thank you very much Justin.Aqualung
I had the same issue and applied all fixes (installing x86 or editing web.config or placing a symlink) suggested here and other places with no avail. It turns out that after you apply these fixes you also have to restart WAS with the following commands from Powershell or Command Prompt: "net stop was" & "net start w3svc" Once I ran those commands the fix worked. I found this on the issue page for this specific error: github.com/tjanczuk/iisnode/issues/302Absolutely
@Absolutely thanks man, after an hour I saw this comment and it works. Cheers!Thaxton
S
6

Instead of installing the 32-bit version, you can create a symbolic link from the 32-bit path to the 64-bit one.

At the cmd.exe prompt:

mklink /D "C:\Program Files (x86)\nodejs" "C:\Program Files\nodejs"

Surprising that this still isn't fixed and the web.config setting seems to be ignored.

Steelwork answered 24/12, 2012 at 4:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.