【问题标题】:Error running node app in WebMatrix在 WebMatrix 中运行节点应用程序时出错
【发布时间】:2012-10-16 06:18:43
【问题描述】:

我安装了 WebMatrix 并按照these 的说明在我的 Windows 7 机器上安装 IIS 7。

当我点击“运行”来运行我的 express 节点应用程序时,浏览器会弹出并告诉我

iisnode 模块无法启动 node.exe 进程。确保 node.exe 可执行文件在 web.config 的 system.webServer/iisnode/@nodeProcessCommandLine 元素中指定的位置可用。默认情况下,node.exe 预计安装在 x86 系统上的 %ProgramFiles%\nodejs 文件夹和 x64 系统上的 %ProgramFiles(x86)%\nodejs 文件夹中。

这是我的 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>

是什么导致了这个问题,我该如何解决?

【问题讨论】:

    标签: node.js runtime-error webmatrix webmatrix-2


    【解决方案1】:

    使用 node.js(64 位),尝试将其放在 web.config 的底部

    <iisnode watchedFiles="*.js;node_modules\*;routes\*.js;views\*.jade" 
    nodeProcessCommandLine="\program files\nodejs\node.exe"/>
    

    【讨论】:

    • 这对我也有帮助。 %ProgamFiles% 环境变量似乎没有扩展。对其中的值进行硬编码是有效的。
    • 我知道它发布后很长时间,但这有效。谢谢
    【解决方案2】:

    如果您从网站安装了 x64 版本的 node,这是一个常见问题。当前 IISNode 设置为从 x32 路径读取 node.exe。您可以更改 nodeProcessCommandLine 以在您的机器上使用 node.exe 的完整路径,或者安装 32 位节点安装。我们正在努力解决这个问题,以便 32/64 位都可以开箱即用。如果这不是问题,请告诉我:)

    【讨论】:

    • "&amp;quot;%programfiles%\nodejs\node.exe&amp;quot;" 不是完整路径吗?
    • 我安装了 32 位版本,是的 - 它现在可以工作了。非常感谢贾斯汀。
    • 我遇到了同样的问题,并应用了此处和其他地方建议的所有修复(安装 x86 或编辑 web.config 或放置符号链接),但无济于事。事实证明,在应用这些修复程序后,您还必须使用 Powershell 或命令提示符中的以下命令重新启动 WAS:“net stop was”和“net start w3svc” 一旦我运行了这些命令,修复程序就起作用了。我在这个特定错误的问题页面上找到了这个:github.com/tjanczuk/iisnode/issues/302
    • @Conor 谢谢伙计,一个小时后我看到了这条评论,它起作用了。干杯!
    【解决方案3】:

    您可以创建一个从 32 位路径到 64 位路径的符号链接,而不是安装 32 位版本。

    cmd.exe 提示符处:

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

    令人惊讶的是,这仍然没有修复,web.config 设置似乎被忽略了。

    【讨论】:

      猜你喜欢
      • 2016-12-28
      • 2021-12-31
      • 1970-01-01
      • 2020-04-05
      • 1970-01-01
      • 2018-01-04
      • 2015-01-05
      • 2016-04-05
      • 1970-01-01
      相关资源
      最近更新 更多