我在没有 Nodejs 的 IIS 服务器上部署和运行 ReactRedux 模板时遇到问题。该应用程序是使用 AspNetCore.SpaTemplates 的“reactredux”选项创建的:https://blogs.msdn.microsoft.com/webdev/2017/02/14/building-single-page-applications-on-asp-net-core-with-javascriptservices/ https://blogs.msdn.microsoft.com/webdev/2017/02/14/building-single-page-applications-on-asp-net-core-with-javascriptservices/
该应用程序与模板相同,没有进行任何更改。我们首先尝试将其托管在 IIS 上,并在 IIS 服务器上安装了 Nodejs,一切正常:
用nodejs截图 https://i.stack.imgur.com/5dTZu.png
但是当我们从服务器上卸载 Node js 并重新启动 IIS 时,它就不再工作了:
没有nodejs的截图 https://i.stack.imgur.com/nRAHf.png
我们无法弄清楚错误是什么,因为在开发模式下运行它需要nodejs,而当我们使用dotnet run
在开发模式下,错误消息抱怨 Node.js 未按预期安装。
我们尝试部署运行的应用程序:
$Env:ASPNETCORE_ENVIRONMENT = "Production"
dotnet publish -c Release
并使用 Visual Studiobuild>publish
界面。
根据此处的文档,应用程序在部署用于生产时不需要 Nodejs:
https://learn.microsoft.com/en-us/aspnet/core/spa/react?tabs=visual-studio https://learn.microsoft.com/en-us/aspnet/core/spa/react?tabs=visual-studio
与开发构建不同,生产构建不需要
要在服务器上安装 Node.js。
我是 ASP.NET 和在 IIS 上部署应用程序的新手,也许解决方案很简单,但我们无法解决这个问题,提前致谢。