Visual Studio 2017 中是否有办法自动启用对 asp.net-core Angular 项目的 Docker 支持?创建新选项时该选项被禁用。它仅适用于Web 应用程序 (MVC)。
在创建项目后,我能够为 Angular 项目启用 Docker 支持(项目->添加->Docker 支持),但是当我启动应用程序时,我收到一个异常,即 node.js 不可用。
System.AggregateException occurred HResult=0x80131500 Message=One or more errors occurred. (Failed to start Node process. To resolve this:.
[1] Ensure that Node.js 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 Node executable is in one of those directories, or update your PATH.
[2] See the InnerException for further details of the cause.)
Source= StackTrace: at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) at Microsoft.AspNetCore.Builder.WebpackDevMiddleware.UseWebpackDevMiddleware(IApplicationBuilder appBuilder, WebpackDevMiddlewareOptions options) at WebApplication3.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env) in C:\Users\temp\Documents\Visual Studio 2017\Projects\WebApplication3\Startup.cs:line 34Inner Exception 1: InvalidOperationException: Failed to start Node process. To resolve this:.
[1] Ensure that Node.js 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 Node executable is in one of those directories, or update your PATH.
[2] See the InnerException for further details of the cause.
Inner Exception 2: Win32Exception: No such file or directory
如果无法自动创建它,如何手动为我的 Angular 项目启用 Docker 支持?
最佳答案
我解决了我的问题。
我还需要在我的镜像上安装nodejs,因为webpack需要它。我已更改 Dockerfile 以安装 Nodejs 版本 6
FROM microsoft/aspnetcore:2.0
RUN apt-get update && \
apt-get install -y wget && \
apt-get install -y gnupg2 && \
wget -qO- https://deb.nodesource.com/setup_6.x | bash - && \
apt-get install -y build-essential nodejs
# Rest of Dockerfile
仅使用RUN apt-get update && apt-get install -y nodejs
是不够的,因为这会安装nodejs的版本4,并且它安装在文件夹nodejs
中,因此 WebpackDevMiddleware
找不到节点可执行文件。
关于angular - 为 Angular 项目启用 Docker 支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45880460/