Docker(file) .net core angular 7 wdm 由于节点问题编译失败.(包括 SPA 中间件)



我试图通过docker容器中的spa中间件运行一个有角度的.NET Core应用程序。 当我在Visual Studio 2017 Pro中创建一个新的角度应用程序并添加docker支持时,它最初失败,因为我需要安装NPM。所以我添加了样板代码来安装我在 dockerfile 中从网上翻录的 NodeJs:

(顺便说一句:在删除角度 5 后,我做了新的 ClientApp,以获得带有 css 样式的版本 7)

FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
# Setup NodeJs
RUN apt-get update && 
apt-get install -y wget && 
apt-get install -y gnupg2 && 
wget -qO- https://deb.nodesource.com/setup_11.x | bash - && 
apt-get install -y build-essential nodejs
# End setup
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM microsoft/dotnet:2.2-sdk AS build
# Setup NodeJs
RUN apt-get update && 
apt-get install -y wget && 
apt-get install -y gnupg2 && 
wget -qO- https://deb.nodesource.com/setup_11.x | bash - && 
apt-get install -y build-essential nodejs
# End setup
WORKDIR /src
COPY ["A7NCDS/A7NCDS.csproj", "A7NCDS/"]
RUN dotnet restore "A7NCDS/A7NCDS.csproj"
COPY . .
WORKDIR "/src/A7NCDS"
RUN dotnet build "A7NCDS.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "A7NCDS.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "A7NCDS.dll"]

当我在 docker 中运行它时,一切正常!但是现在当我删除我的客户端应用程序并使用 SCSS 而不是 CSS 执行新的客户端应用程序时,我收到此错误:

Error: Missing binding /app/ClientApp/node_modules/node-sass/vendor/linux-x64-67/binding.node
Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 11.x
Found bindings for the following environments:
- Windows 64-bit with Node.js 11.x

所以我做了一些googleFU,最终将npm rebuild node-sass放在我的Dockerfile中,我现在丢失了,这给了我一个模糊的错误,没有细节:WDM编译失败。

我如何让它工作?我现在太卡住了。我没有对.csproj文件或启动.cs进行任何更改。我正在考虑完全删除 SCSS/SASS,但这不是一个现实的务实解决方案。(如果其他一些库完全成为特定于平台的库怎么办?

你使用的是哪个版本的nodejs和npm?您是否尝试过重建npm rebuild node-sass从您的项目文件夹中?还尝试删除 npm 缓存并重新安装节点模块。 还尝试全局安装 sass,

npm install -g sass

码头工人文件示例

FROM ubuntu:16.04
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y apt-utils
RUN apt-get install -y sudo
RUN apt-get install -y curl && apt-get install -y ssh
RUN apt-get install -y libfontconfig && apt-get install -y git
RUN curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
RUN apt-get install -y nodejs
RUN apt-get install -y build-essential
RUN npm install -g @angular/cli
COPY apache.pem /
COPY package.json /
RUN npm install
EXPOSE 4200

最新更新