最近再Server 2012 + IIS 8 中配置NodeJS 运行环境,具体配置过程就不细说了(随便搜搜一堆),安装完nodejs 和 iisnode 之后,出现一个报错,如下:

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

 

google 了半天,刚开始以为是x86NodeJS安装路径的问题,后来倒腾半天始终不对,后来找到篇文章 https://admin-ahead.com/forum/websitepanel/node-js-error!/

解决方法:在web.config 》system.webServer 节点加上:

<iisnode watchedFiles="*.js;node_modules\*;routes\*.js;views\*.jade"  nodeProcessCommandLine="C:\Program Files\node.exe"/>

问题解决,我鸟个去,希望能帮助到后面遇到此问题的童靴,我的web.config 文件如下,供参考:

 

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

        <iisnode watchedFiles="*.js;node_modules\*;routes\*.js;views\*.jade"  nodeProcessCommandLine="C:\Program Files\node.exe"/>
    </system.webServer>
</configuration>