github action npm run build not working, but works locally

Viewed 3107

Our team created a react web app and want to use github action to push the project to Kuberntes. Here is the 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;"]

when I run docker locally with command

docker build --tag abc:test .

It built the image successfully. But when I push it github action, it will stop at RUN npm run build:staging. And the Error message is

/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.

Any idea?

0 Answers
Related