CI building docker fails with `compatibilityVersion: 4` but local typcheck/building works
Environment
- Operating System: Windows_NT
- Node Version: v20.16.0
- Nuxt Version: ^3.13.2
- CLI Version: 3.13.2
- Nitro Version: -
- Package Manager: [email protected]
- Builder: -
- User Config: app, future, modules, ssr, typescript, eslint, i18n, tailwindcss, components, imports, primevue, experimental, nitro, hooks, spaLoadingTemplate, devtools, compatibilityDate
- Runtime Modules: @nuxt/fonts@^0.8.0, @nuxtjs/i18n@^8.5.4, @nuxtjs/tailwindcss@^6.12.1, @vueuse/nuxt@^11.1.0, @nuxt/eslint@^0.5.7, @pinia/nuxt@^0.5.4, @vee-validate/nuxt@^4.13.2, @primevue/nuxt-module@^4.0.7
- Build Modules: -
Reproduction
Code: https://github.com/frasza/docker-ci-failing CI example: https://github.com/frasza/docker-ci-failing/actions/runs/10965378202/job/30451050880#step:6:295
Describe the bug
After upgrading up from 3.13.0 I have been getting fails from a lot of Typescirpt errors inside CI Docker build, while I am not getting there errors from local nuxi typecheck or nuxi generate or docker build.
If I am to downgrade to 3.13.0 it seems to work fine.
Additional context
No response
Logs
No response
Stackblitz link for the reproduction: Stackblitz
@danielroe as we discussed regarding the difference between local and CI build in Docker, I have finally managed to copy the project and prepare some sample for Github Actions (we are using gitlab) to reproduce. 🙏
After further investigation and testing, it seems to be related to compatibilityVersion: 4 config. If I move everything off app dir and remove compat config, it seems to work.
I encountered exactly the same problem and spent more time on it than I would have liked.
So, what I found out. You can see in your docker log the following sequence of actions:
- installing packages (npm ci)
- generating types (postinstall > nuxt prepare)
- copying your stuff to the container
- building (nuxt generate or nuxt build)
Mine was the same.
I discovered that exactly before building .nuxt/nuxt.d.ts and .nuxt/tsconfig.json (inside the container) does not contain specific stuff from my project like modules, custom types, etc.
So, running type generation just before build fixes this issue, e.g.:
RUN npm ci
COPY . .
RUN nuxi prepare && npm run generate
The open question is why switching the compatibilityVersion flag changes the behaviour.
That indicates it might be related to the new build directory behaviour, which uses .nuxt solely for types, and node_modules/.cache/nuxt/.nuxt for production builds (if the .nuxt/ directory exists)
@danielroe Is there any update regarding this? I haven't had a time to check but just to get an update and possibly resolve an issue.
I think the issue here is that you are running the install without any files present, which makes the generated .nuxt folder inaccurate (it's missing all the types).
Copying the files before the install should work instead:
FROM node:lts-alpine AS build
WORKDIR /app
COPY . ./
RUN npm ci
Need to confirm why it wasn't failing before, and address, just in case.
i'm still getting types error after generate the .nuxt folder
example of .Dockerfile
# Build the Nuxt application
RUN bun run postinstall
RUN bun run build
error logs
=> ERROR [builder 6/6] RUN bun run build 10.7s
------
> [builder 6/6] RUN bun run build:
0.141 $ nuxt build
0.189 [nuxi] Nuxt 3.18.1 with Nitro 2.12.4
0.797 [nuxt:tailwindcss] ℹ Using Tailwind CSS from ~/assets/css/tailwind.css
5.207 [nuxt] ℹ Running with compatibility version 4
5.207 [nuxi] ℹ Building for Nitro preset: node-server
6.122 ℹ Building client...
6.141 ℹ vite v7.1.3 building for production...
6.169 ℹ transforming...
10.36 components/Blackout/ResultTable/columns.ts(5,35): error TS2307: Cannot find module '~/components/Blackout/ResultTable/DataTableColumnHeader.vue' or its corresponding type declarations.
10.36 components/Blackout/ResultTable/columns.ts(6,33): error TS2307: Cannot find module '~/components/Blackout/ResultTabl