gpt4 book ai didi

angular - 由于节点 sass,Docker(file) .net core angular 7 wdm 无法编译。 (包括 SPA 中间件)

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

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

(顺便说一句:我在删除 angular 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 中运行它时,一切正常!但是现在当我删除我的 ClientApp 并使用 SCSS 支持而不是 CSS 执行新的 ClientApp 时,我收到了这个错误:
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 文件或 startup.cs 进行任何更改。我正在考虑完全删除 SCSS/SASS,但这不是一个现实的务实解决方案。 (如果其他一些库完全成为特定于平台的呢?)

最佳答案

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

npm install -g sass

docker 文件示例
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

关于angular - 由于节点 sass,Docker(file) .net core angular 7 wdm 无法编译。 (包括 SPA 中间件),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55351279/

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