nestjs + typeorm + ncc missing class-validator and class-transformer

See original GitHub issue

i run ncc build ./src/main.ts -o and run node index.js.

display these tips.

[PackageLoader] The "class-validator" package is missing. Please, make sure to install this library ($ npm install class-validator) to take advantage of ValidationPipe. +4ms

and

[PackageLoader]  The "class-transformer" package is missing. Please, make sure to install this library ($ npm install class-transformer) to take advantage of ValidationPipe. +18ms

and then i run yarn init && yarn add class-validator yarn add class-transformer.

it works. 👍

but if there is a better way to solve it so that i don’t need to use yarn add?


btw. i want to thxs @dirkdev98 in https://github.com/zeit/ncc/issues/245 's solution. help me fixed typeorm error.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
SolidZOROcommented, Mar 18, 2019

BTW,

if your use ncc build nest.js 6.0.0, see this error [PackageLoader] No driver (HTTP) has been selected. In order to take advantage of the default driver, please, ensure to install the "@nestjs/platform-express" package ($ npm install @nestjs/platform-express).

you can try declare type use express.


before:

const app = await NestFactory.create(AppModule);

after:

const server = express();
const app = await NestFactory.create(AppModule, new ExpressAdapter(server));
1reaction
styflecommented, Mar 23, 2019

when packages are listed in the dependencies section of the package.json file, shouldn’t they always be included by ncc?

No, the purpose of ncc is to remove unnecessary code. For example, the dependency might be in package.json but if you never require() it then it won’t be included in the bundled output.

Sometimes ncc misses dynamic code which why we still have issues reported here 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

nestjs + typeorm + ncc missing class-validator and ... - GitHub
i run ncc build ./src/main.ts -o and run node index.js. display these tips. [PackageLoader] The "class-validator" package is missing.
Read more >
Cannot find module 'class-transformer' or its corresponding ...
I am trying to use the class-transformer package with NestJS v7. ... from "typeorm"; import { Expose } from 'class-transformer'; ...
Read more >
NestJS REST API: class-validator & class-transformer - Medium
In this short post, we will try to focus on how to start implementing the class-validator and class-transformer libraries. Both of them are...
Read more >
11. Class Validator and Class Transformer Packages - YouTube
In this video, we install the packages required to perform server side validation of the data being sent from the frontend.
Read more >
NestJS with TypeORM and Postgres - Better Programming
In today's article, I want to develop a small project based on NestJS, ... npm i @nestjs/config @nestjs/typeorm typeorm pg class-validator class-transformer
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found