Next.js Discord

Discord Forum

Linting fails when building with docker

Unanswered
Crucian carp posted this in #help-forum
Open in Discord
Crucian carpOP
If I build my project normally via npm run build, no error message regarding the linting appears. However, when I try to build a Docker container, I suddenly get linting errors that always have something with the type "any".
What could be the reason for this?

17 Replies

Crucian carpOP
Bump
Toyger
what errors do you get? where is logfile?
what content of your dockerfile?
Crucian carpOP
Thats my error:
> web-shop@0.1.0 build > next build ▲ Next.js 14.2.3 - Environments: .env Creating an optimized production build ... (process:30): VIPS-WARNING **: 11:19:38.657: threads clipped to 1024 ✓ Compiled successfully Linting and checking validity of types ... Failed to compile. ./src/app/(customerFacing)/cart/_actions/products.ts:11:6
Type error: Parameter 'item' implicitly has an 'any' type. 9 | 10 | const productInCart = cart.cartItems.find( > 11 | (item) => item.productId === productId, | ^ 12 | ); 13 | 14 | if (quantity === 0) {
Toyger
it basically show you error and where it is
./src/app/(customerFacing)/cart/_actions/products.ts:11:6
Type error: Parameter 'item' implicitly has an 'any' type.

why you are using typescript if you don't type things?
you can add :any to your item parameter, but probably it's not the only problem that will arise.
you can change noImplicitAny to false, in your tsconfig, but again you most likely will have other errors with typescript.
@Crucian carp I don't actually have any errors, because everything works in dev mode as well as in production. Even when I run `npm run build` locally, I don't get any errors. Only docker shows an error.
Toyger
it's only set environment to production
so if your npm run build && npm run start works fine result should be same.
maybe you are not copying some files
@Himalayan Do you have "noImplicitAny" set in your tsconfig?
Crucian carpOP
Nope:
{ "compilerOptions": { "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, "strict": true, "noEmit": true, "esModuleInterop": true, "module": "esnext", "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, "jsx": "preserve", "incremental": true, "plugins": [ { "name": "next" } ], "paths": { "@/*": ["./src/*"] } }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], "exclude": ["node_modules"] }
Himalayan
Properly because of strict being set to true, im pretty sure it also enables noImplicitAny
Himalayan
Either that or properly type your code
@Himalayan Either that or properly type your code
Crucian carpOP
Okay. But why doesn't my IDE show me that type of errors?
Himalayan
Try and run "npm run lint" locally
Crucian carpOP
✔ No ESLint warnings or errors
Toyger
try to remove node_modules and run install again, maybe update nodejs too.
but for some reason your runtime ignoring typescript errors