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.
[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
- Add class-validator and class-transformer to dependencies.
- Run
npm ciso they are restored in CI. - Re-run so the ValidationPipe can load them.
npm install class-validator class-transformerKeep 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 ciso installs match the lockfile. - Add a startup smoke test in CI so missing validators are caught.