Skip to content
Latchkey

NestJS "class-validator" / "class-transformer" not installed in CI

Nest logs a warning that class-validator or class-transformer is not installed, so the ValidationPipe cannot run and requests pass unvalidated. Both packages must be declared dependencies.

What this error means

Startup logs "class-validator" or "class-transformer" packages are missing, or a Cannot find module error for them appears, and DTO validation never runs.

NestJS
[Nest] WARN "class-validator" and "class-transformer" packages are missing. Please,
make sure to install both packages to ensure the ValidationPipe works correctly.
Error: Cannot find module 'class-validator'

Common causes

The validation packages are not declared dependencies

They were installed transitively or globally on a dev machine but never added to package.json, so a clean CI install omits them.

They were pruned as devDependencies

A production-only install dropped them even though the running app needs them at runtime.

How to fix it

Install both packages as dependencies

  1. Add class-validator and class-transformer to dependencies.
  2. Run npm ci so they are restored in CI.
  3. Re-run so the ValidationPipe can load them.
Terminal
npm install class-validator class-transformer

Keep them out of devDependencies

Because the runtime app uses them, they belong in dependencies, not devDependencies, so production installs keep them.

How to prevent it

  • Declare class-validator and class-transformer as runtime dependencies.
  • Use npm ci so installs match the lockfile.
  • Add a startup smoke test in CI so missing validators are caught.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →