AggregateException:发生一个或多个错误. (发生一个或多个错误.(无法启动"npm".要解决此问题,请执行以下操作: [英] AggregateException: One or more errors occurred. (One or more errors occurred. (Failed to start 'npm'. To resolve this:

查看:2512
本文介绍了AggregateException:发生一个或多个错误. (发生一个或多个错误.(无法启动"npm".要解决此问题,请执行以下操作:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用docker的Mac上的Visual Studio遇到很多错误,感到沮丧.我在asp.net core 2.1上有一个项目,在docker image上有角度为6.当项目成功构建但无法在下面运行时,详细信息为:

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 :

在处理请求时发生未处理的异常. AggregateException:发生一个或多个错误. (发生一个或多个错误.(无法启动"npm".要解决此问题:. 1 确保已安装"npm",并且可以在其中一个PATH目录中找到它. 当前的PATH环境变量是:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 确保可执行文件在这些目录之一中,或更新您的PATH. 2 有关原因的更多详细信息,请参见InnerException.)) System.Threading.Tasks.Task.GetResultCore(bool waitCompletionNotification) InvalidOperationException:无法启动"npm".解决此问题的方法: 1 确保已安装"npm",并且可以在PATH目录之一中找到它. 当前的PATH环境变量是:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 确保可执行文件在这些目录之一中,或更新您的PATH. 2 有关原因的更多详细信息,请参见InnerException. Microsoft.AspNetCore.NodeServices.Npm.NpmScriptRunner.LaunchNodeProcess(ProcessStartInfo startInfo)

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)

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/";
            });

这是docker文件信息

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:无法启动节点进程

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

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

推荐答案

最后解决此问题.此问题是由于未在asp.net core 2.1 docker映像上安装node.js造成的.

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

因此将节点js安装在Docker容器中

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

在修改和更改节点版本值之前,请检查节点的版本.就我而言,我有8.11.3,所以 setup_8.x

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

完整的docker文件

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

源- https://github.com/aspnet/Announcements/issues/298 为ASP.NET Core 2.1 Angular配置Dockerfile项目

这篇关于AggregateException:发生一个或多个错误. (发生一个或多个错误.(无法启动"npm".要解决此问题,请执行以下操作:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆