Typescript errors only on GitHub Actions

79 views Asked by At

I have a React+Vite project and below Dockerfile. When I run this locally all works fine. But on GitHub actions I get errors like Cannot find module '@/components/ui/Button' or its corresponding type declarations and error TS7006: Parameter 'e' implicitly has an 'any' type

FROM node:20-slim AS nodebase
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
COPY ./frontend/app /app
WORKDIR /app

FROM nodebase AS nodebuild
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build

I deleted my node_modules directory locally, cleared Docker image cache, deleted pnpm store files and still not able to replicate this locally. I am not sure why I get these errors on GitHub actions only.

1

There are 1 answers

0
SupaCoda On

To debug the issue I added below to my Dockerfile which listed the TS config and files and I compared this output to the one on my local machine.

RUN pnpm tsc --showConfig

It turned out that I had changed the casing of a few filenames, eg. I renamed button.tsx to Button.tsx. This was not detected by Git and the file in repo was still having lowercase B.

I used git mv to rename the files again and pushed the changes. After this is started working.