Docker节点alpine node-sass模块构建失败,甚至运行了“ npm rebuild node-sass”

时间:2019-06-16 06:27:27

标签: node.js docker webpack node-sass

我正在为我的项目使用Docker node-alpine。

我的项目结构是这样的

Project
  /client (for front end client where is need node-sass)
    package.json
    webpack.js
  index.js
  package.json

这是我的dockerfile

FROM node:8.16.0-alpine

RUN mkdir /app
WORKDIR /app

# --no-cache: download package index on-the-fly, no need to cleanup afterwards
# --virtual: bundle packages, remove whole bundle at once, when done
RUN apk --no-cache --virtual build-dependencies add \
    python \
    make \
    g++ \
    bash

RUN npm install -g nodemon

COPY package.json package.json
COPY client/package.json client/package.json

RUN npm install
RUN npm run install:client
RUN cd client && npm rebuild node-sass --force
# RUN npm run sass:rebuild:client

COPY . .

LABEL maintainer="Varis Darasirikul"

VOLUME ["/app/public"]

CMD npm run dev

这是我客户中的webpack条规则

{
        test: /\.(sa|sc|c)ss$/,
        exclude: /node_modules/,
        use: [
          {
            loader: MiniCssExtractPlugin.loader,
            options: {
              hmr: process.env.NODE_ENV === 'development',
              // if hmr does not work, this is a forceful method.
              reloadAll: true,
            },
          },
          'css-loader',
          'postcss-loader',
          'sass-loader',
        ],
      },

但是在我尝试在webpack-dev-server文件夹中运行client之后。 我收到此错误。

Node Sass could not find a binding for your current environment: Linux/musl 64-bit with Node.js 8.x
Run `npm rebuild node-sass` to download the binding for your current environment.

我已经在dockerfile里面做过事。

那么我该如何解决我在docker文件中丢失的所有内容?

谢谢!

0 个答案:

没有答案