我已经使用vs2017在mac os中创建了一个角度应用程序,并在示例表单Creating a new Angular project on Mac with Visual Studio之后使用docker支持三个项目。由于其他项目是Web API。由于其他项目在docker上成功运行。但是只有角度应用程序没有运行,它会抛出错误,如下所示
System.AggregateException: "One or more errors occurred. (Failed to start Node process. To resolve this:.\n\n[1] Ensure that Node.js is installed and can be found in one of the PATH directories.\n Current PATH enviroment variable is: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\n Make sure the Node executable is in one of those directories, or update your PATH.\n\n[2] See the InnerException for further details of the cause.)" ---> System.Exception {System.InvalidOperationException}: "Failed to start Node process. To resolve this:.\n\n[1] Ensure that Node.js is installed and can be found in one of the PATH directories.\n Current PATH enviroment variable is: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\n Make sure the Node executable is in one of those directories, or update your PATH.\n\n[2] See the InnerException for further details of the cause." ---> System.Exception {System.ComponentModel.Win32Exception}: "No such file or directory"
at at System.Diagnostics.Process.ResolvePath(String filename)\n at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)\n at System.Diagnostics.Process.Start()\n at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)\n at Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance.LaunchNodeProcess(ProcessStartInfo startInfo)
--- End of inner exception stack trace ---
at at Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance.LaunchNodeProcess(ProcessStartInfo startInfo)\n at Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance..ctor(String entryPointScript, String projectPath, String[] watchFileExtensions, String commandLineArguments, CancellationToken applicationStoppingToken, ILogger nodeOutputLogger, IDictionary`2 environmentVars, Int32 invocationTimeoutMilliseconds, Boolean launchWithDebugging, Int32 debuggingPort)\n at Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance..ctor(NodeServicesOptions options, Int32 port)\n at Microsoft.AspNetCore.NodeServices.HostingModels.NodeServicesOptionsExtensions.<>c__DisplayClass0_0.<UseHttpHosting>b__0()\n at Microsoft.AspNetCore.NodeServices.NodeServicesImpl.CreateNewNodeInstance()\n at Microsoft.AspNetCore.NodeServices.NodeServicesImpl.GetOrCreateCurrentNodeInstance()\n at Microsoft.AspNetCore.NodeServices.NodeServicesImpl.<InvokeExportWithPossibleRetryAsync>d__10`1.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)\n at Microsoft.AspNetCore.Builder.WebpackDevMiddleware.UseWebpackDevMiddleware(IApplicationBuilder appBuilder, WebpackDevMiddlewareOptions options)\n at WebApp.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env) in /Users/macbook/Projects/MeroRental/WebApp/Startup.cs:line 34\n--- End of stack trace from previous location where exception was thrown ---\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\n at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)\n at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder builder)\n at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()\n at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()\n at WebApp.Program.BuildWebHost(String[] args) in /Users/macbook/Projects/MeroRental/WebApp/Program.cs:line 21\n at WebApp.Program.Main(String[] args) in /Users/macbook/Projects/MeroRental/WebApp/Program.cs:17
尝试解决此链接https://github.com/aspnet/JavaScriptServices/issues/707中的错误,但没有结果。
答案 0 :(得分:0)
从这个链接找到解决方案并且它有效。
https://github.com/aspnet/JavaScriptServices/issues/1534#issuecomment-366605094
修改了角度app docker文件
更改此行
FROM microsoft/aspnetcore:2.0 AS base
到
FROM microsoft/aspnetcore-build:2.0 AS base
更新了Docker文件
FROM microsoft/aspnetcore-build:2.0 AS base
WORKDIR /app
EXPOSE 80
FROM microsoft/aspnetcore-build:2.0 AS build
WORKDIR /src
COPY MeroRental.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"]