【问题标题】:client&admin react-scripts: not found客户端和管理员反应脚本:未找到
【发布时间】:2020-01-30 22:45:07
【问题描述】:

我正在尝试使用 docker 映像安装 api-platform。问题是容器无法启动,并以代码 127 退出。

$ react-scripts start
/bin/sh: react-scripts: not found
error Command failed with exit code 127.

我正在将 Docker 用于带有 Linux 容器的 Windows。我尝试了我能想到的一切。我在支持中发现的唯一一件事是重建客户端和管理员,但无济于事。有人出主意吗?

我使用 api-plaform 提供的 Docker 文件:https://github.com/api-platform/api-platform

Dockerfile 管理员: #https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage #https://docs.docker.com/compose/compose-file/#target

# https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
ARG NODE_VERSION=13
ARG NGINX_VERSION=1.17


# "development" stage
FROM node:${NODE_VERSION}-alpine AS api_platform_admin_development

WORKDIR /usr/src/admin

# prevent the reinstallation of node modules at every changes in the source code
COPY package.json yarn.lock ./
RUN set -eux; \
    apk add --no-cache --virtual .gyp \
        g++ \
        make \
        python \
    ; \
    yarn install; \
    apk del .gyp

COPY . ./

VOLUME /usr/src/admin/node_modules

ENV HTTPS true

CMD ["yarn", "start"]

# "build" stage
# depends on the "development" stage above
FROM api_platform_admin_development AS api_platform_admin_build

ARG REACT_APP_API_ENTRYPOINT

RUN set -eux; \
    yarn build

# "nginx" stage
# depends on the "build" stage above
FROM nginx:${NGINX_VERSION}-alpine AS api_platform_admin_nginx

COPY docker/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf

WORKDIR /usr/src/admin/build

COPY --from=api_platform_admin_build /usr/src/admin/build ./

Dockerfile:客户端 #https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage #https://docs.docker.com/compose/compose-file/#target

# https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
ARG NODE_VERSION=13
ARG NGINX_VERSION=1.17


# "development" stage
FROM node:${NODE_VERSION}-alpine AS api_platform_client_development

WORKDIR /usr/src/client

RUN yarn global add @api-platform/client-generator

# prevent the reinstallation of node modules at every changes in the source code
COPY package.json yarn.lock ./
RUN set -eux; \
    yarn install

COPY . ./

VOLUME /usr/src/client/node_modules

ENV HTTPS true

CMD ["yarn", "start"]


# "build" stage
# depends on the "development" stage above
FROM api_platform_client_development AS api_platform_client_build

ARG REACT_APP_API_ENTRYPOINT

RUN set -eux; \
    yarn build


# "nginx" stage
# depends on the "build" stage above
FROM nginx:${NGINX_VERSION}-alpine AS api_platform_client_nginx

COPY docker/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf

WORKDIR /usr/src/client/build

COPY --from=api_platform_client_build /usr/src/client/build ./

【问题讨论】:

  • 你能提供你的 Dockerfile 吗?
  • 我已经更新了我的帖子。谢谢。

标签: reactjs docker api-platform.com


【解决方案1】:

我遇到了同样的问题。 我通过在两个目录(/client/admin)中直接输入yarn install 解决了这个问题。然后您可以启动docker 图像(docker-compose up -d)。

希望对你有帮助。

【讨论】:

    猜你喜欢
    • 2012-05-30
    • 2014-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-14
    • 1970-01-01
    • 1970-01-01
    • 2018-08-23
    相关资源
    最近更新 更多