#Live reload not working on windows 11
38 messages · Page 1 of 1 (latest)
got a repository to share? Otherwise I don't think we can help you out
Sure But its been happening with every Nest Project on my PC including a nx monorepo as well and through different ts versions as well. So I will share one if you need
Did you try a reboot? 😁
Yes ofc, also have tried reinstalling even nodejs, let alone nestCli
What is the log if you set DEBUG=* and NEST_DEBUG=true env variables (don't know how that's done on windows).
you mean these logs
[Nest] 10400 - 24/01/2024, 8:33:15 pm LOG [NestApplication] Nest application successfully started +2345ms
[Nest] 10400 - 24/01/2024, 8:33:15 pm LOG 🚀 Application is running on: http://localhost:3000
if I add these variables to my env file?
If yes then no errors as such, just the mapping info, but I did found this log which I don't understand,
express:router use '/' <anonymous> +10ms
express:router:layer new '/' +0ms
express:router use '/' <anonymous> +2ms
express:router:layer new '/' +0ms
anyways Idk if its useful
Not necessarily into env file, since that could be read too late. Looks like set DEBUG='*' probably? (https://www.opentechguides.com/how-to/article/windows-11/222/path-environment-variable.html).
Anyway, what more than "🚀 Application is running" do you expect?
sorry if I didn't phrase my response or question correctly, ofc it starts correctly but doesn't reload on change and no logs are there once a change is made thus it is stuck on waiting for file changes
Additionally I have tested the same code (multiple repos) and watch mode works perfectly in MacOs
Live reload not working on windows 11
You could try tweaking the watchOptions, see https://stackoverflow.com/a/75789242/2078771
Is it installed on a normal drive, or some virtual/network drive?
Normal Drive. Tried the solution but now it doesn't even work detects a file change when adding wathcOptions to tsconfig.buid.json and gets stuck if I add the same wathcOptions to tsconfig.json
So I didn't check the backend for a few days as I was working on Azure and FrontEnd. Was trying to install Openssl and deleted my path in environment vars, then reinstalled everything back and I believe since then this issue started appearing. Here are ss of path env:
- User
- System
Although Idk if its related to it
I don't have other ideas, as I don't develop on Windows, sorry. I'm almost certain that it's not a Nest issue, that any typescript project will have the same issue.
You could google for "windows typescript live reload not working", maybe you'll find something, until someone using win eventually helps here.
Ok Well I have researched for tsc --watch not working as well 😁. But anyways thanks for your help.
what watchOptions did you try?
The ones mentioned here https://stackoverflow.com/a/75789242/2078771
Additionally have tried all values of watchFile
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.
did you also try fixedPollingInterval?
Yes
This is also mentioned here: https://docs.nestjs.com/faq/common-errors#file-change-detected-loops-endlessly
Nest is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with TypeScript and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming).
I have tried almost everything as I been working on this issue for at least a full day now as without live/hot reload I can't work properly. And Have tried hot reload using webpack.hmr method from Nest docs but that also doesn't work after 2+ changes just compiles and doesn't run the code. Also there is no typechecking in it
what IDE and terminal do you use on windows?
vsCode and powershell
*Recently updated wsl as well (if useful to this convo)
Tried running on Wsl as well, same problem
have you recently changed any 'file save' related settings in vscode?
Npe
nope*
its the same from the start
if you believe it only happens on your side, try testing with another editor and terminal, like the git bash or the command prompt
Tried reinstalling vscode and tried running on cmd. Yet the same problem 🙃
I suggested testing with another editor because they have different methods of saving file changes on disk.
some might truncate and rewrite the entire file, some might only update what is changed, and others may create a temporary file, delete the original one, and then move the temporary file to the correct location. if you leave their settings by default, they choose whichever works best based on file system permissions. some might confuse tsc's watch mode.
I don't think "reinstalling" it makes any difference because the editor's configuration usually remains the same :v
Ok I will give it a try
So an update, I tried a random solution from stack overflow which was to create a new resource nest g resource xxxxx --no-spec. It works but only when I change anything in this particular resource. Still doesn't work anywhere else.