Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm run start:dev in NestJs not to rebuild when i make some change in my code

Tags:

npm

nestjs

When I run npm run start:dev in NestJs it works like this:

10:00:00 AM - Starting compilation in watch mode...

10:00:10 AM - Found 0 errors. Watching for file changes.
Debugger listening on ws://127.0.0.1:9229/0cb76900-3b46-4f68-82c0-ea78ed36f327
For help, see: https://nodejs.org/en/docs/inspector
[Nest] 3932   - 03/06/2020, 10:00:23 AM   [NestFactory] Starting Nest application...
[Nest] 3932   - 03/06/2020, 10:00:23 AM   [InstanceLoader] JwtModule dependencies initialized +41ms
[Nest] 3932   - 03/06/2020, 10:00:23 AM   [InstanceLoader] ConfigHostModule dependencies initialized +2ms
[Nest] 3932   - 03/06/2020, 10:00:23 AM   [InstanceLoader] ConfigModule dependencies initialized +2ms

enter image description here

But when I changed the code it was not rebuilt. It just shows like this:

10:40:27 AM - File change detected. Starting incremental compilation...

10:40:27 AM - Found 0 errors. Watching for file changes.

enter image description here

Can anyone help me to fix it? Thanks very much.

like image 847
Khánh Nguyễn Avatar asked Sep 16 '25 01:09

Khánh Nguyễn


2 Answers

It has something to do with Circular Dependency as stated here: https://docs.nestjs.com/fundamentals/circular-dependency. Simply means some module which are depended on each other are called recursively which as I learnt from https://stackoverflow.com/users/8966778/ruslan-gonzalez in the NestJs community, makes the app fail from starting up which he also helped me fix.

If you can create a minimal repo and share the link, so I can check it for you

like image 109
NotNull Avatar answered Sep 18 '25 16:09

NotNull


The reason why the logging is not being shown is because you may have the logger disable in your configuration since the tsc shows that compiling is fine but nothing else, checkout the main.ts file and enable the logger.

const app = await NestFactory.create(AppModule, {
    logger: false,
  });

to

const app = await NestFactory.create(AppModule);

Hope that helps!

like image 41
Ruslan Gonzalez Avatar answered Sep 18 '25 18:09

Ruslan Gonzalez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!