我在我的ASP.Net核心应用程序中使用Microsoft.AspNetCore.NodeServices 1.1.1。一切都很正常,但现在我在一台新计算机上,我得到了以下错误:
System.InvalidOperationException:
Failed to start Node process. To resolve this:.
[1] Ensure that Node.js is installed and can be found in one of the PATH directories.
Current PATH enviroment variable is: ....
Make sure the Node executable is in one of those directories, or update your PATH.
[2] See the InnerException for further details of the cause.我已经从这个问题中删除了path变量,但其中列出了安装Node的目录。
终端中的node -v为我提供了v6.11.0,因此它被添加到路径中。
自从上次工作以来,代码中没有任何变化,只有我的计算机。有没有人知道可能出了什么问题?
发布于 2017-06-20 14:59:08
调试后,我发现这是由于文件夹丢失。
这就是在Startup.cs中配置NodeServices的方式
services.AddNodeServices(options =>
{
options.ProjectPath = "Path\That\Doesnt\Exist";
});一旦我添加了该路径,一切都运行正常。
发布于 2018-11-30 11:40:39
您可以使用此代码片段来获取客户端项目
services.AddNodeServices(options =>{
options.ProjectPath = Path.Combine(Directory.GetCurrentDirectory(), "ClientApp"); });发布于 2019-10-02 17:21:46
对我来说,这个错误是在将我的网站从Net Core2.2升级到3.0之后造成的。
升级改变了我的web.config文件,特别是这部分:
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\MyWebsite.exe" arguments="" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />变成这样:
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" hostingModel="inprocess">
<environmentVariables>
<environmentVariable name="COMPLUS_ForceENC" value="1" />
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>我修复了这个问题,将processPath和arguments设置回之前的值,并完全删除了<environmentVariables>部分。
https://stackoverflow.com/questions/44635280
复制相似问题