在IIS中托管Angular Universal时出错:iisnode在处理请求时遇到错误



我试图为facebook共享动态更改我的Angular 8元标签
我在C#上有后端API
但除了将现有应用程序转换为服务器端之外,我在任何地方都找不到任何解决方案

因此,我正试图在Windows Server 2019的IIS中托管我的Angular 8通用应用程序。
我在托管网站的根目录中有dist文件夹、main.js和web.config文件
我已经在服务器中安装了iisnode
当我浏览网站时,会在根目录上创建一个空白的iisnode文件夹
我已将IIS_IUSR的完全控制权限设置为根目录的IUSR
但我收到以下错误:

错误

我的文件夹结构如下:

文件夹

我的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> 
<iisnode node_env="production" nodeProcessCountPerApplication="0" nodeProcessCommandLine="C:Program Filesnodejsnode.exe" interceptor="C:Program Filesiisnodeinterceptor.js" />
</system.webServer>
</configuration>

我被这个问题卡住了,无法继续下去
请帮帮我。

更新(23-12-2021(:
我对角度代码进行了一些更改,这个问题已经解决。但是显示了一个新的错误,如下所示:

iisnode在处理请求时遇到错误。

HRESULT:0x2 HTTP状态:500 HTTP子状态:1002 HTTP原因:内部服务器错误您收到此HTTP 200响应是因为system.webServer/isnode/@devErrorsEnabled配置设置为"true"。

除了node.exe进程的stdout和stderr的日志之外,考虑使用调试和ETW跟踪来进一步诊断问题

node.exe进程生成的输出到stderr的最后64k如下所示:

应用程序引发了未捕获的异常并被终止:错误:找不到模块"zone.js/dist/zone node"需要堆栈:

  • C:\inetpub\wwwroot\AdvAngularServer\main.js
  • C: \Program Files(x86(\iisnode\interceptor.js位于Function.Module.resolveFilename(internal/modules/cjs/loader.js:880:15(位于Function.Module_load(internal/modules/cjs/loader.js:725:27(在Module.require(internal/modules/cjs/loader.js:952:19(at required(internal/modules/cjs/helpers.js:88:18(位于Object.b6Xn(C:\inetpub\wwwroot\AdvAngularServer\main.js:1:6605(在webpack_require(C:\inetpub\wwwroot\AdvAngularServer\main.js:1:317(位于Module.uj+Y(C:\inetpub\wwwroot\AdvAngularServer\main.js:1:21026(在webpack_require(C:\inetpub\wwwroot\AdvAngularServer\main.js:1:317(位于Object.0(C:\inetpub\wwwroot\AdvAngularServer\main.js:1:2902(在webpack_require(C:\inetpub\wwwroot\AdvAngularServer\main.js:1:317(

有什么想法吗?

有一个用户"NetworkServices";或者类似的东西。。。您已经尝试将此用户添加到windows权限中了吗?我在wordpress上遇到了问题,我可以用它来解决。

我认为你没有dist文件夹的权限,或者你在模块区域节点的代码中有错误的路径

我通过在包.json中添加--bundleDependencies all解决了这个问题。
谢谢。

最新更新