question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ng build --watch and ng serve don't always build updated files after new changes

See original GitHub issue

I usually need to save changes multiple times in order for angular-cli to actually build files with those changes.

OS?

Ubuntu 16.10 x64

Versions.

angular-cli: 1.0.0-beta.28.3 node: 7.1.0 os: linux x64

Repro steps.

This happens for any angular-cli app I make, even fresh ones.

In the log below you can see the initial build when running ng build --watch with Hash: 91bb893998276a59bbb3. Then I make a change to app.component.ts and save it. Angular-cli responds with those next builds with the same Hash: 91bb893998276a59bbb3 which results in dist files without the new change. I go back to app.component.ts and save again. Finally angular-cli responds with new Hash: 99e3be9aeef7c621e6f3 and the dist files include the new change.

The log given by the failure.

Hash: 91bb893998276a59bbb3
Time: 7868ms
chunk    {0} polyfills.bundle.js, polyfills.bundle.map (polyfills) 222 kB {4} [initial] [rendered]
chunk    {1} main.bundle.js, main.bundle.map (main) 3.94 kB {3} [initial] [rendered]
chunk    {2} styles.bundle.js, styles.bundle.map (styles) 10 kB {4} [initial] [rendered]
chunk    {3} vendor.bundle.js, vendor.bundle.map (vendor) 2.38 MB [initial] [rendered]
chunk    {4} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry] [rendered]
Hash: 91bb893998276a59bbb3
Time: 625ms
chunk    {0} polyfills.bundle.js, polyfills.bundle.map (polyfills) 222 kB {4} [initial]
chunk    {1} main.bundle.js, main.bundle.map (main) 3.94 kB {3} [initial]
chunk    {2} styles.bundle.js, styles.bundle.map (styles) 10 kB {4} [initial]
chunk    {3} vendor.bundle.js, vendor.bundle.map (vendor) 2.38 MB [initial]
chunk    {4} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry]
Hash: 91bb893998276a59bbb3
Time: 594ms
chunk    {0} polyfills.bundle.js, polyfills.bundle.map (polyfills) 222 kB {4} [initial]
chunk    {1} main.bundle.js, main.bundle.map (main) 3.94 kB {3} [initial]
chunk    {2} styles.bundle.js, styles.bundle.map (styles) 10 kB {4} [initial]
chunk    {3} vendor.bundle.js, vendor.bundle.map (vendor) 2.38 MB [initial]
chunk    {4} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry]
Hash: 91bb893998276a59bbb3
Time: 568ms
chunk    {0} polyfills.bundle.js, polyfills.bundle.map (polyfills) 222 kB {4} [initial]
chunk    {1} main.bundle.js, main.bundle.map (main) 3.94 kB {3} [initial]
chunk    {2} styles.bundle.js, styles.bundle.map (styles) 10 kB {4} [initial]
chunk    {3} vendor.bundle.js, vendor.bundle.map (vendor) 2.38 MB [initial]
chunk    {4} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry]
Hash: 99e3be9aeef7c621e6f3
Time: 526ms
chunk    {0} polyfills.bundle.js, polyfills.bundle.map (polyfills) 222 kB {4} [initial]
chunk    {1} main.bundle.js, main.bundle.map (main) 3.97 kB {3} [initial] [rendered]
chunk    {2} styles.bundle.js, styles.bundle.map (styles) 10 kB {4} [initial]
chunk    {3} vendor.bundle.js, vendor.bundle.map (vendor) 2.38 MB [initial]
chunk    {4} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry]
Hash: 99e3be9aeef7c621e6f3
Time: 576ms
chunk    {0} polyfills.bundle.js, polyfills.bundle.map (polyfills) 222 kB {4} [initial]
chunk    {1} main.bundle.js, main.bundle.map (main) 3.97 kB {3} [initial]
chunk    {2} styles.bundle.js, styles.bundle.map (styles) 10 kB {4} [initial]
chunk    {3} vendor.bundle.js, vendor.bundle.map (vendor) 2.38 MB [initial]
chunk    {4} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry]

Mention any other details that might be useful.

I thought this problem might be due to the Inotify Watches Limit on Linux that has been mentioned in some issues but setting it to 524288 does not fix the problem and it seems to me that angular-cli knows when the changes happen but doesn’t include them in the build for some reason. Also none of the directories have spaces or special characters in their name and webpack runs fine in other projects.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
efstathiosntonascommented, Feb 9, 2017

This is a known issue, going back to “@ngtools/webpack” : “1.2.4” fixes the issue but you will lose the new perfomance improvements in building time of version 1.2.6 and up.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 7, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular - ng serve not detecting file changes automatically
Most of the times in Linux, ng serve or ng build --watch doesn't work if the directory doesn't have sufficient permissions.
Read more >
ng build does not detect changes? : r/angular - Reddit
Hey, I'm working on a couple of changes for an angular project and they're seemingly not going through. After saving the files in...
Read more >
Identify and Fix Build and Deployment Errors in Your Angular ...
In this guide, you will learn how to spot some of the most common build and deployment errors and how to resolve them...
Read more >
Angular: Watch Build for Changes - JavaScript in Plain English
As you make changes to a file, the watch recompiles and rebuilds the code. The dist/application-name directory is updated with the latest code....
Read more >
Creating libraries - Angular
ng new my-workspace --no-create-application cd my-workspace ng generate library my- ... the workspace configuration file, angular.json , is updated with a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found