Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AggregateException: One or more errors occurred. (One or more errors occurred. (Failed to start 'npm'. To resolve this:

Visual studio on mac with docker is having lots of error getting frustration . I, have a project on asp.net core 2.1 with angular 6 on docker image. When The project is successfully builded but not able to run below is the details :

An unhandled exception occurred while processing the request. AggregateException: One or more errors occurred. (One or more errors occurred. (Failed to start 'npm'. To resolve this:. 1 Ensure that 'npm' is installed and can be found in one of the PATH directories. Current PATH enviroment variable is: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin Make sure the executable is in one of those directories, or update your PATH. 2 See the InnerException for further details of the cause.)) System.Threading.Tasks.Task.GetResultCore(bool waitCompletionNotification) InvalidOperationException: Failed to start 'npm'. To resolve this:. 1 Ensure that 'npm' is installed and can be found in one of the PATH directories. Current PATH enviroment variable is: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin Make sure the executable is in one of those directories, or update your PATH. 2 See the InnerException for further details of the cause. Microsoft.AspNetCore.NodeServices.Npm.NpmScriptRunner.LaunchNodeProcess(ProcessStartInfo startInfo)

info for details

added more image

services.AddNodeServices(options =>
            {
                options.ProjectPath = "/Library/Frameworks/Mono.framework/Commands:/Applications/Visual Studio.app/Contents/Resources:/Applications/Visual Studio.app/Contents/MacOS:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:/usr/local/bin/";
            });

Here is the docker file info

FROM microsoft/dotnet:2.1-sdk AS base
WORKDIR /app
EXPOSE 80

FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY MeroRentalDev.sln ./
COPY WebApp/WebApp.csproj WebApp/
RUN dotnet restore -nowarn:msb3202,nu1503
COPY . .
WORKDIR /src/WebApp
RUN dotnet build -c Release -o /app

FROM build AS publish
RUN dotnet publish -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "WebApp.dll"]

Tried many solution for the link but not able to solve System Aggregation Exception : Failed to start Node Process

Microsoft.AspNetCore.NodeServices: Failed to start node process

https://github.com/aspnet/JavaScriptServices/issues/227

https://github.com/aspnet/JavaScriptServices/issues/707

like image 310
San Jaisy Avatar asked Jun 14 '18 13:06

San Jaisy


2 Answers

Finally Solve the issue. This issue was due to node.js is not install on asp.net core 2.1 docker image.

So install the node js in docker container

# Setup NodeJs
RUN apt-get update && \
    apt-get install -y wget && \
    apt-get install -y gnupg2 && \
    wget -qO- https://deb.nodesource.com/setup_8.x | bash - && \
    apt-get install -y build-essential nodejs
# End setup

check the version of node before you modify and change the node version value. In my case I,have 8.11.3 so setup_8.x

Full docker file

FROM microsoft/dotnet:2.1-sdk AS base

    # Setup NodeJs
    RUN apt-get update && \
        apt-get install -y wget && \
        apt-get install -y gnupg2 && \
        wget -qO- https://deb.nodesource.com/setup_8.x | bash - && \
        apt-get install -y build-essential nodejs
    # End setup
    WORKDIR /app
    EXPOSE 80

    FROM microsoft/dotnet:2.1-sdk AS build
    WORKDIR /src
    COPY MeroRentalDev.sln ./
    COPY WebApp/WebApp.csproj WebApp/
    RUN dotnet restore -nowarn:msb3202,nu1503
    COPY . .
    WORKDIR /src/WebApp
    RUN dotnet build -c Release -o /app

    FROM build AS publish
    RUN dotnet publish -c Release -o /app

    FROM base AS final
    WORKDIR /app
    COPY --from=publish /app .
    ENTRYPOINT ["dotnet", "WebApp.dll"]

source - https://github.com/aspnet/Announcements/issues/298 Configuring Dockerfile for an ASP.NET Core 2.1 Angular Project

like image 53
San Jaisy Avatar answered Nov 07 '22 18:11

San Jaisy


I'm going to post another potential cause of the issue (albeit one that is somewhat related to the existing answer) in the interest of helping those searching the error message.


In addition to the current answer(s), this error can also arise if you're (mistakenly or otherwise) running with the ASPNETCORE_ENVIRONMENT env var set to 'Development' in non-Dev environments.


For instance, if you have code such as below in Startup.cs, and you've (deliberately) not installed npm in the environment in question, you'll see the aforementioned error message when your Dotnet app tries to run npm start.

if (env.IsDevelopment())
{
    spa.UseAngularCliServer(npmScript: "start");
}

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-3.1

like image 36
derekbaker783 Avatar answered Nov 07 '22 18:11

derekbaker783