Enable Docker support for Angular project [duplica

2020-02-29 11:11发布

Is there a way in Visual Studio 2017 to automatically enable Docker support for an asp.net-core Angular project? The option is disabled when creating a new one. It is only available for Web Application (MVC).

I am able to Enable Docker support (Project->Add->Docker Support) for the angular project after I have created the project, but when I start the application I get an exception that node.js is not available.

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 34

Inner 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

If it is not possible to create it automatically how can I manually get the Docker support enabled for my Angular project?

1条回答
爷的心禁止访问
2楼-- · 2020-02-29 11:25

I solved my problem.

I needed to install nodejs also on my image, cause it is needed by webpack. I have changed my Dockerfile to also install nodejs version 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

Using only RUN apt-get update && apt-get install -y nodejs was not enough, cause this installs version 4 of nodejs and it was installed in folder nodejs, so that the WebpackDevMiddleware did not find the node executable.

查看更多
登录 后发表回答