我需要在我的docker容器中运行npm rebuild node-sass --force
但是我得到了一个错误(即使我已经安装了python )
Error: Can't find Python executable "python", you can set the PYTHON env variable.这是我的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 \
&& npm install \
&& apk del build-dependencies
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 npm uninstall node-sass && npm install node-sass
RUN npm rebuild node-sass --force
COPY . .
LABEL maintainer="Varis Darasirikul"
VOLUME ["/app/public"]
CMD npm run dev这是我的docker-compose
version: '3'
services:
web:
build: '.'
container_name: node-web
# env_file:
# - '.env'
ports:
- '80:8000'
- '5000:5000'
- '3000:3000'
volumes:
- '.:/app'
networks:
- front-tier
- back-tier
# depends_on:
# - redis
# - db
networks:
front-tier:
back-tier:即使我跑步的时候
docker-compose up --build --force-recreate还是不能工作
如何解决这个问题?
谢谢!
发布于 2019-06-15 22:45:58
问题是Python根本没有安装。
您的父映像node:8.16.0-alpine不包含Python。您可以验证这一点:
> docker run -it node:8.16.0-alpine sh
/ # python
sh: python: not found误解可能来自于这样一个事实,即您在该行上临时安装python:
RUN apk --no-cache --virtual build-dependencies add \
python \
...它被添加到虚拟包build-dependencies中,但就在npm install完成之后,您运行apk del build-dependencies再次删除Python!
只需在完成所有npm rebuild工作后,将卸载build-dependencies的行移动到该行,我认为它会起作用。
发布于 2020-09-07 14:34:55
因为您使用的是不包含python的小图像alpine图像。您可以通过运行apk add来安装python,并在安装节点模块后将其删除。
FROM node:alpine
RUN apk add --no-cache --virtual .gyp \
python \
make \
g++ \
&& npm install \
&& apk del .gyp发布于 2021-02-23 19:59:03
另一种解决方案是使用bcryptjs。性能可能并不重要,但是使用工作而不是应用变通方法!
https://stackoverflow.com/questions/56611283
复制相似问题