Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft.AspNetCore.NodeServices: Failed to start node process

Tags:

asp.net-core

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?

like image 593
Joel Avatar asked Jun 19 '17 16:06

Joel


2 Answers

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.

like image 189
Joel Avatar answered Nov 11 '22 11:11

Joel


You can use this code snippet to get a client project

 services.AddNodeServices(options =>{
              options.ProjectPath = Path.Combine(Directory.GetCurrentDirectory(), "ClientApp");  });
like image 22
bc120200358 Avatar answered Nov 11 '22 09:11

bc120200358