Search code examples
terminalwindows-10angular-clicommand-prompt

How to clear the Angular CLI command line after each compilation


I'm using Angular CLI 9.0.3 on Windows 10, inside the standard Windows command prompt, to run ng build.

When there are errors reported in the command prompt, it can be difficult to determine how far back to scroll in order to see the first error in the current compilation.

Using MacOS it's possible to use Command-k to clear the terminal while it's running, but to my knowledge the Windows requires you to stop the service then use cls to clear the command prompt.

Is there a way to clear the terminal automatically each time the app compiles, so that I can scroll to the top of the command window to see the first error?


Solution

  • Since Angular 17 you can use --clear-screen when serving the application. Or you can add it to the angular.json under the build options.

    more info in Angular docs