angular: ⚠️ Local development bugs with HMR

Which @angular/* package(s) are the source of the bug?

compiler-cli

Is this a regression?

Yes

Description

We’re aware of reports of local development bugs arising from Angular template HMR in 19.1.x, which has been enabled by default.

List of known issues:

  • [Fixed in 19.1.2] #59581
  • [Fixed in 19.1.2] #59592
  • [Fixed in 19.1.2] angular/angular-cli#29248
  • [Fixed in 19.1.3(CLI)] #59605
  • [Fixed in 19.1.4(CLI)] angular/angular-cli#29424
  • [Fixed in 19.1.3] #59632
  • [Fixed in 19.1.3] #59634
  • [Fixed in 19.1.3] #59639
  • [Fixed in 19.1.3] #59640

We’re actively investigating and fixing these issues to create a smooth HMR experience out of the box. Production builds and releases are not affected. If you discover any additional HMR challenges which don’t appear to be related to the linked issues above, verify that you are on a recent version (19.1.3+), and please file a new issue and link it here so we can triage and investigate.

Workarounds

In the meantime, if you encounter any problems relating to HMR, you can work around them in three ways:

  1. Refresh the page - This loads a fresh copy of your application with up to date code.
  2. ng serve --no-hmr - This disables HMR for your local devserver and automatically refreshes the page on any code changes.
  3. Disable HMR for your project - Configuring angular.json will disable HMR for all ng serve invocations by default.
    • This is useful for a project with a large number of developers without needing to communicate these workarounds to all contributors.
    • Remember to re-enable once the relevant issues are fixed!
{
  "projects": {
    "my-project": {
      "architect": {
        "serve": {
          "options": {
            "hmr": false
          }
        }
      }
    }
  }
}

Thank you for sharing any HMR issues and helping improve Angular one bugfix at a time. We’re committed to fully stabilizing this feature and excited to bring improved build performance to everyone.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 48
  • Comments: 37 (8 by maintainers)

Most upvoted comments

When we are adding tailwind classes it is not getting reflected due to hmr .

We’ve released versions 19.1.3 of the framework and 19.1.4 of the CLI which resolve the outstanding HMR issues. If you were encountering issues previously, please consider updating and let us know if you encounter any HMR or reload related problems.

I updated all my projects to use “@angular/core”: “19.1.2” & “@angular/cli”: “19.1.3”. But now when I start the dev server using “ng serve” and visit the localhost:4200, the nodejs server crashes with the following error:

` NOTE: Raw file sizes do not reflect development server per-request transformations. ➜ Local: http://localhost:4200/ ➜ press h + enter to show help node:internal/process/promises:394 triggerUncaughtException(err, true /* fromPromise */); ^

Error: [vite] cannot find entry point module ‘file:///D:/<PROJECT_FOLDER>/.angular/vite-root/spa-near-me/@ng/component?c=src%2Fapp%2Fcomponents%2Fheader%2Fheader.component.ts%40HeaderComponent&t=1737401566323’. at fetchModule (file:///D:/<PROJECT_FOLDER>/node_modules/@angular/build/node_modules/vite/dist/node/chunks/dep-BJP6rrE_.js:51477:13) at async handleInvoke (file:///D:/<PROJECT_FOLDER>/node_modules/@angular/build/node_modules/vite/dist/node/chunks/dep-BJP6rrE_.js:44166:22) at async EventEmitter.listenerForInvokeHandler (file:///D:/<PROJECT_FOLDER>/node_modules/@angular/build/node_modules/vite/dist/node/chunks/dep-BJP6rrE_.js:44239:19) {`

All my projects are using tailwind CSS and I’ve also enabled provideExperimentalZonelessChangeDetection() .

This problem goes away if I use ng serve --no-hmr.

Here are my dependencies "dependencies": { "@angular/animations": "^19.1.2", "@angular/common": "^19.1.2", "@angular/compiler": "^19.1.2", "@angular/core": "^19.1.2", "@angular/forms": "^19.1.2", "@angular/platform-browser": "^19.1.2", "@angular/platform-browser-dynamic": "^19.1.2", "@angular/platform-server": "^19.1.2", "@angular/router": "^19.1.2", "@angular/ssr": "^19.1.3", "express": "^4.18.2", "rxjs": "~7.8.0", "tslib": "^2.3.0", "zone.js": "~0.15.0" }, "devDependencies": { "@angular-devkit/build-angular": "^19.1.3", "@angular/cli": "^19.1.3", "@angular/compiler-cli": "^19.1.2", "@types/express": "^4.17.17", "@types/jasmine": "~5.1.0", "@types/node": "^18.18.0", "autoprefixer": "^10.4.20", "daisyui": "^4.12.23", "jasmine-core": "~5.5.0", "karma": "~6.4.0", "karma-chrome-launcher": "~3.2.0", "karma-coverage": "~2.2.0", "karma-jasmine": "~5.1.0", "karma-jasmine-html-reporter": "~2.1.0", "lucide-angular": "^0.473.0", "postcss": "^8.5.1", "prettier": "^3.4.2", "tailwindcss": "^3.4.17", "typescript": "~5.7.2", "xmlbuilder": "^15.1.1" }

I am on core 19.1.7 / cli 19.1.8 – template HMR is not working at all. No errors thrown. Template changes simply don’t get reflected. I had to disable HMR entirely to reload on template changes.

I do see the update event coming through the dev websocket, though. Just nothing happens in the DOM.

Image

We are also encountering issues with the HMR. We have nx workspace v20.4.0 with all the latest Angular packages and it’s not working. Are there some configurations/architecture/executors that might disable the HMR from working?

Thanks in advance 😃

I can confirm that with 19.1.4 still, with HMR active, application doesn’t get refreshed regularly. Full app refresh is needed. This makes it frustrating, especially when developing with Tailwind.

@clydin I have figured the issue out !

Reason : if you are having project which is created before core: 9.1.3 and cli: 9.1.4 even if you are updating core and cli packages as @angular-devkit/* are not added as dev dependency it’s not getting updated even if you are running command ng update

Image

Solution : you have to manually update it by running ng update @angular-devkit/core and it would work fine !

Question : @clydin is there any reason behind not updating those dependencies by ng update asking just out of curiosity.

@YashrajDawkhar During a rebuild, Tailwind may internally change other aspects of the application even though a developer may have only made changes to a template. This typically occurs when new Tailwind classes are added to a template and currently requires a full page reload. More advanced Tailwind support is being investigated including built-in support for the recently released Tailwind v4.

@kunjgit Please ensure that all Angular packages have been updated. If you are still encountering problems, please open a separate issue with details of the problem as well as the output of ng version and a minimal reproduction, if possible.

I have updated to the latest ng core/cli and can confirm all the errors, warning messages are all gone now. I can run Angular projects locally without using --no-hmr flag now. Amazing support from Angular team as always! 👏👏

In my case HMR doesn’t work at all, i tried to enable it, but it still reload page after each change in styles and templates

Same here. I get the “Component HMR has been enabled” warning, so I think it’s enabled. But any changes to components, templates, or styles always causes a browser refresh. ng serve --verbose doesn’t say anything of interest, is there some way to enable more verbose logging?

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 19.2.8
Node: 22.15.1
Package Manager: npm 11.4.0
OS: darwin arm64

Angular: 19.2.7
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1902.8
@angular-devkit/build-angular   19.2.8
@angular-devkit/core            19.2.8
@angular-devkit/schematics      19.2.8
@angular/cdk                    19.2.10
@angular/cli                    19.2.8
@schematics/angular             19.2.8
ng-packagr                      19.1.0
rxjs                            7.8.1
typescript                      5.7.3
zone.js                         0.15.0

Update: Seems like "aot": false is the reason. https://github.com/angular/angular-cli/issues/30352

All known problems have been addressed as of 19.2.0.

If you encounter any new issues with component HMR, please open a separate issue and include a minimal reproduction if possible.

The issue with the statsJson will be fixed by https://github.com/angular/angular-cli/pull/29707.

I can also confirm that even updated packages have warnings for HMR.

Image

For anyone following along, we’ve released versions 19.1.2 of the framework and 19.1.3 of the CLI to resolve the outstanding HMR issues.

I registered a possible issue with lazy loaded components here

There was a fix in the CLI version 19.1.3 that reloads the page in the presence of $localize, although I’m not sure if it made its way to Nx.