When I build project myself using yarn build
it works properly, but when I build docker container it gives me typescript error. A week before everything was working fine.
No overload matches this call.
#12 97.88 Overload 1 of 2, '(props: InfiniteScrollProps | Readonly<InfiniteScrollProps>): InfiniteScroll', gave the following error.
#12 97.88 Type 'React.ReactNode' is not assignable to type 'import("/app/node_modules/@types/styled-components/node_modules/@types/react/index").ReactNode'.
#12 97.88 Overload 2 of 2, '(props: InfiniteScrollProps, context: any): InfiniteScroll', gave the following error.
#12 97.88 Type 'React.ReactNode' is not assignable to type 'import("/app/node_modules/@types/styled-components/node_modules/@types/react/index").ReactNode'. TS2769
My dockerfile
FROM node:16-alpine as build
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package.json ./
RUN yarn
COPY . ./
ARG REACT_APP_BASE_URL
ENV REACT_APP_BASE_URL $REACT_APP_BASE_URL
RUN CI=false yarn run build
# production environment
FROM nginx:stable-alpine
COPY --from=build /app/build /usr/share/nginx/html
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
CodePudding user response:
as @David Maze already answered it is probably due to a mismatch of your packages. We had a similar issue with NPM, and we had to solve it by copying the lock file as well.
COPY package.json package-lock.json .npmrc ./
Besides that make sure you are using the same node version locally and on the CI server/build image, some packages can be different between the versions (node 12 - 16, we had some issues with devs locally running 10 or 12 and the CI system was on 16).