Reactjs github操作npm运行构建不工作,但在本地工作

Reactjs github操作npm运行构建不工作,但在本地工作,reactjs,docker,npm,github-actions,Reactjs,Docker,Npm,Github Actions,我们的团队创建了一个react web应用程序,并希望使用github操作将项目推送到Kuberntes。以下是Dockerfile: ### STAGE 1: Build ### FROM node:14.5.0 as build RUN mkdir -p /src/app WORKDIR /src/app # Install app dependencies COPY package.json /src/app/ RUN npm install && \ npm

我们的团队创建了一个react web应用程序,并希望使用github操作将项目推送到Kuberntes。以下是Dockerfile:

### STAGE 1: Build ###
FROM node:14.5.0 as build

RUN mkdir -p /src/app
WORKDIR /src/app

# Install app dependencies
COPY package.json /src/app/
RUN npm install && \
    npm install -g pushstate-server

# Bundle app source
COPY . /src/app

# Build and optimize react app
RUN npm run build:staging

### STAGE 2: Production Environment ###
FROM nginx:1.19.2
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /src/app/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
当我使用命令在本地运行docker时

docker build --tag abc:test .
它成功地建立了形象。但当我将它推到github操作时,它将在
运行npm RUN build:staging
时停止。错误消息是

/src/app/src/Components/SideBar/SideBarLinks/index.tsx
TypeScript error in /src/app/src/Components/SideBar/SideBarLinks/index.tsx(124,9):
Property 'children' is missing in type '*** onEntered: () => void; ***' but required in type 'CollapseProps'.  TS2741

    122 |         dropdownWrapperProps=*** 'data-tour': 'support-wrapper' ***
    123 |         dropdownToggleProps=*** 'data-tour': 'support-dropdown-button' ***
  > 124 |         collapseProps=***
        |         ^
    125 |           onEntered: () => ***
    126 |             const sidebarItemsWrapper = document.querySelector(
    127 |               '.side-bar-items-wrapper'

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-09-21T06_19_14_044Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! dashboard_redo@4.0.0 api:staging: `cross-env REACT_APP_API_BASE_URL=https://staging.jetsonai.com/api/v3 npm run integrations-url:staging "npm" "run" "build"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the dashboard_redo@4.0.0 api:staging script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-09-21T06_19_14_076Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! dashboard_redo@4.0.0 build:staging: `cross-env REACT_APP_MODE=test npm run api:staging npm run build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the dashboard_redo@4.0.0 build:staging script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-09-21T06_19_14_093Z-debug.log
The command '/bin/sh -c npm run build:staging' returned a non-zero code: 1

##[error]Process completed with exit code 1.

有什么想法吗?

看起来像是打字稿的问题。检查您是否正在使用
package.lock
,这样您的DEP在Github worker中将与之相同…尝试一下
npm ci
,因为它将在您的package-lock.json中查找,以安装具有确切版本的所有依赖项,如果问题是版本不匹配,则尝试在本地执行产品构建脚本,成功了吗?@felixmosh-ya。我们正在使用包锁。json@Vikas嗯。这是成功的。将尝试
npm ci