Khánh Nguyễn
Khánh Nguyễn

Reputation: 41

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

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.

Upvotes: 4

Views: 8491

Answers (4)

In my case i realised that I didn't save my code ,

Nestjs will only re-compile a code if it notices any changes ,Incase of no changes it won't ,so it's possible you didn't save your code on ur code editor.

Upvotes: -2

In my case it worked for me by deleting the dist folder and recompiling the project

Upvotes: 0

NotNull
NotNull

Reputation: 61

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

Upvotes: 5

Ruslan Gonzalez
Ruslan Gonzalez

Reputation: 182

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!

Upvotes: 1

Related Questions