Joel
Joel

Reputation: 8948

Microsoft.AspNetCore.NodeServices: Failed to start node process

I'm using Microsoft.AspNetCore.NodeServices 1.1.1 in my ASP.Net Core application. Everything has been working fine, but now I'm on a new computer and I get the following error:

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.

I have removed the path variables from this question, but the directory where Node is installed is listed in there.

node -v in a terminal gives me v6.11.0 so it is added to the path.

Nothing in the code has changed since it last worked, only my computer. Does anyone know what could be wrong?

Upvotes: 5

Views: 14281

Answers (3)

Stuart Aitken
Stuart Aitken

Reputation: 1012

For me the error was caused after upgrading my website from Net Core 2.2 to 3.0.

The upgrade altered my web.config file, in particular this part:

<handlers>
    <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>

<aspNetCore processPath=".\MyWebsite.exe" arguments="" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />

became this:

<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>

I fixed the issue by setting processPath and arguments back their previous values, and completely removed the <environmentVariables> section.

Upvotes: 0

bc120200358
bc120200358

Reputation: 11

You can use this code snippet to get a client project

 services.AddNodeServices(options =>{
              options.ProjectPath = Path.Combine(Directory.GetCurrentDirectory(), "ClientApp");  });

Upvotes: 1

Joel
Joel

Reputation: 8948

After debugging I found out that it was due to a missing folder.

This is how NodeServices was configured in Startup.cs:

services.AddNodeServices(options =>
{
    options.ProjectPath = "Path\That\Doesnt\Exist";
});

Once I added that path, everything runs okay.

Upvotes: 8

Related Questions