gpt4 book ai didi

angular - 为 Angular 项目启用 Docker 支持

转载 作者:行者123 更新时间:2023-12-02 20:26:42 25 4
gpt4 key购买 nike

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 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

如果无法自动创建它,如何手动为我的 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com