在 IIS 10 上部署 angular 通用

Deploy angular universal on IIS 10

我正在尝试在 IIS 10 上部署 angular 通用,我遵循了这篇文章 https://www.thecodehubs.com/how-to-deploy-ssr-angular-universal-to-iis/
这是我的 Web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="iisnode" path="main.js" verb="*" modules="iisnode" />
    </handlers>
    <rewrite>
      <rules>
        <rule name="DynamicContent">
          <match url="/*" />
          <action type="Rewrite" url="main.js"/>
        </rule>
        <rule name="StaticContent" stopProcessing="true">
          <match url="([\S]+[.](jpg|jpeg|gif|css|png|js|ts|cscc|less|ico|html|map|svg))" />
          <action type="None" />
        </rule>
      </rules>
    </rewrite>
    <staticContent>
      <clientCache cacheControlMode="UseMaxAge" />
      <remove fileExtension=".svg" />
      <remove fileExtension=".eot" />
      <remove fileExtension=".ttf" />
      <remove fileExtension=".woff" />
      <remove fileExtension=".woff2" />
      <remove fileExtension=".otf" />
      <mimeMap fileExtension=".ttf" mimeType="application/octet-stream" />
      <mimeMap fileExtension=".svg" mimeType="image/svg+xml"  />
      <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
      <mimeMap fileExtension=".woff" mimeType="application/x-woff" />
      <mimeMap fileExtension=".woff2" mimeType="application/x-woff" />
      <mimeMap fileExtension=".otf" mimeType="application/otf" />
    </staticContent>
  </system.webServer>
</configuration>

这是我在 IIS 上的应用文件夹



但是当我在 IIS 上启动我的网站时,出现了这个错误

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.

所以我将这一行添加到我的 web.config 文件中,就在

之前
<iisnode nodeProcessCommandLine="C:\Program Files\nodejs\node.exe" />
  </system.webServer>
</configuration>

但同样的问题仍然存在。这是我的 ProgramFiles,这里 我注意到 nodejs 有快捷方式 ,我正在使用 nvm(节点版本管理器)。是这个原因吗?

是的,你是对的,这是因为你使用的是 nvm,我以前遇到过这个问题。
在 cmd

中 运行ning 关闭节点版本管理器
nvm off

在你的机器上安装 node js,然后 运行 没有任何问题。