5

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?

Joel
  • 8,502
  • 11
  • 66
  • 115

3 Answers3

8

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.

Quality Catalyst
  • 6,531
  • 8
  • 38
  • 62
Joel
  • 8,502
  • 11
  • 66
  • 115
1

You can use this code snippet to get a client project

 services.AddNodeServices(options =>{
              options.ProjectPath = Path.Combine(Directory.GetCurrentDirectory(), "ClientApp");  });
  • Would this not reduce to "ClientApp/" since Directory.GetCurrentDirectory() is the directory containing the assembly? –  Nov 30 '18 at 04:08
  • It will give the current directory of ClientApp and but the above problem is like the PATH environment variable not solved by it. If you have path issue you should set path first – bc120200358 Nov 30 '18 at 05:30
  • Makes more sense now. Since ProjectPath is not set. –  Nov 30 '18 at 07:05
  • I have node v8.11.3 installed. verified by node -v. I have the correct PATH set 100%. I am debugging in vs 2017. I have tried adding the above line and I'm still receiving this error. 'AggregateException: One or more errors occurred. (Failed to start Node process.' – billy jean Jan 26 '19 at 21:04
0

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.

Stuart Aitken
  • 949
  • 1
  • 13
  • 30