#Nestjs watch mode doesn't restart server

12 messages · Page 1 of 1 (latest)

willow river
#

Hi friends, i have global problem,which is the same for all my projects, when i am running an app, after saving the file, it doesn't restart server,i think that problem is with the versions but i am not sure
I an using
"@nestjs/core": "^10.0.0"
NodeJs : 16.16.0
npm: 8.19
typescript: 5.1.3

full umbraBOT
#

Please run the command npx -y @nestjs/cli info and paste the output in a code block. This will help us determine if there is a version issue in your packages and which version of nest we are triaging.

willow river
willow river
# full umbra Please run the command `npx -y @nestjs/cli info` and paste the output in a code ...
[System Information]
OS Version     : Windows 10
NodeJS Version : v20.11.0
NPM Version    : 8.19.2

[Nest CLI]
Nest CLI Version : 10.2.1

[Nest Platform Information]
platform-express version : 10.3.0
mapped-types version     : 2.0.4
schematics version       : 10.0.3
typeorm version          : 10.0.1
testing version          : 10.3.0
common version           : 10.3.0
config version           : 3.1.1
core version             : 10.3.0
cli version              : 10.2.1

full umbraBOT
#

Windows users who are using TypeScript version 4.9 and up may encounter this problem.
This happens when you're trying to run your application in watch mode, e.g npm run start:dev and see an endless loop of the log messages:

XX:XX:XX AM - File change detected. Starting incremental compilation...
XX:XX:XX AM - Found 0 errors. Watching for file changes.

When you're using the NestJS CLI to start your application in watch mode it is done by calling tsc --watch, and as of version 4.9 of TypeScript, a new strategy for detecting file changes is used which is likely to be the cause of this problem.
In order to fix this problem, you need to add a setting to your tsconfig.json file after the "compilerOptions" option as follows:

{
  "watchOptions": {
    "watchFile": "fixedPollingInterval"
  }
}

This tells TypeScript to use the polling method for checking for file changes instead of file system events (the new default method), which can cause issues on some machines.
You can read more about the "watchFile" option in TypeScript documentation.

willow river
willow river
#

@full umbra

lapis briar
#

Try upgrading Nest CLI to the latest verison.

willow river
lapis briar
#

@willow river - I have no more ideas, if you did the suggestions above. Can you run npx -y @nestjs/cli info again please and post the results here?

willow river
# lapis briar <@405078960532226058> - I have no more ideas, if you did the suggestions above. ...
[System Information]
OS Version     : Windows 10.0.22621
NodeJS Version : v20.11.0
NPM Version    : 8.19.2

[Nest CLI]
Nest CLI Version : 10.3.2

[Nest Platform Information]
platform-express version : 10.3.0
mapped-types version     : 2.0.4
schematics version       : 10.0.3
typeorm version          : 10.0.1
testing version          : 10.3.0
common version           : 10.3.0
config version           : 3.1.1
core version             : 10.3.0
cli version              : 10.3.2
lapis briar
#

Sorry, no ideas. 🤷🏻‍♂️ These are the kind of quirks in dev'ing with Windows that made me move to Linux. I tried WSL too, but it was also quirky depending on what I needed to do.