Mac上的Visual Studio与docker有很多错误让人感到沮丧 . 我,在asp.net core 2.1上有一个项目,在docker镜像上有角度6 . 当项目成功构建但无法在下面运行时,详细信息如下:
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文件信息
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"]
尝试了许多链接的解决方案,但无法解决System Aggregation Exception : Failed to start Node Process
Microsoft.AspNetCore.NodeServices: Failed to start node process
1 回答
最后解决这个问题 . 这个问题是由于node.js没有安装在asp.net core 2.1 docker镜像上 .
因此,在docker容器中安装节点js
在修改和更改节点版本值之前,请检查节点的版本 . 在我的情况下,我有8.11.3所以 setup_8.x
完整的docker文件
来源 - https://github.com/aspnet/Announcements/issues/298 Configuring Dockerfile for an ASP.NET Core 2.1 Angular Project