简体   繁体   English

AggregateException:发生一个或多个错误。 (发生一个或多个错误。(无法启动“npm”。要解决此问题:

[英]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 .带有 docker 的 mac 上的 Visual Studio 有很多错误让你感到沮丧。 I, have a project on asp.net core 2.1 with angular 6 on docker image.我,在 docker 镜像上有一个 angular 6 的 asp.net core 2.1 项目。 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. AggregateException:发生一个或多个错误。 (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'. 。(发生一个或多个错误(无法启动“新公共管理”要解决这样的: 1 。确保“故宫”已安装并可以在路径中的一个目录中找到当前PATH环境变量是:在/ usr /本地/ sbin目录:在/ usr / local / bin目录:/ usr / sbin目录:在/ usr / bin中:/ sbin目录:/ bin中确认可执行文件是在这些目录中的一个,或更新您的PATH。 2见的的InnerException针对病因的进一步细节.)) System.Threading.Tasks.Task.GetResultCore(bool waitCompletionNotification) InvalidOperationException:无法启动'npm'。 To resolve this:.要解决这个问题:。 1 Ensure that 'npm' is installed and can be found in one of the PATH directories. 1确保“npm”已安装并且可以在 PATH 目录之一中找到。 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.当前 PATH 环境变量为:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 确保可执行文件位于这些目录之一中,或更新您的 PATH . 2 See the InnerException for further details of the cause. 2有关原因的更多详细信息,请参阅 InnerException。 Microsoft.AspNetCore.NodeServices.Npm.NpmScriptRunner.LaunchNodeProcess(ProcessStartInfo startInfo) 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/";
            });

Here is the docker file info这是docker文件信息

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

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

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

Finally Solve the issue.最后解决问题。 This issue was due to node.js is not install on asp.net core 2.1 docker image.此问题是由于 node.js 未安装在 asp.net core 2.1 docker 映像上。

So install the node js in docker container所以在docker容器中安装node js

# 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就我而言,我有 8.11.3 所以setup_8.x

Full docker file完整的 docker 文件

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源 - https://github.com/aspnet/Announcements/issues/298 为 ASP.NET Core 2.1 Angular 项目配置 Dockerfile

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.除了当前的答案之外,如果您(错误地或以其他方式)在非开发环境中将ASPNETCORE_ENVIRONMENT env var 设置为“开发”,也会出现此错误。


For instance, if you have the code 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 .例如,如果您在Startup.cs有以下代码,并且您(故意)未在相关环境中安装npm ,则当您的 Dotnet 应用程序尝试运行npm start时,您将看到上述错误消息。

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM