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?
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.
You can use this code snippet to get a client project
services.AddNodeServices(options =>{
options.ProjectPath = Path.Combine(Directory.GetCurrentDirectory(), "ClientApp"); });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With