The real issue here is the Node version. I'm guessing you might be using the "latest" version of Node, right? When I encountered this issue, it was during local testing, where some of the build commands wouldn't execute because the program (or the terminal at runtime) would get stuck on some supposed "completed" tasks, usually related to the build or strange ng completion scripts. But anyway, this had nothing to do with Angular.
To verify this, I repeatedly uninstalled and installed various versions of Angular CLI, but to no avail. Finally, I suspected it was a Node version issue. At some point, I had updated Node to an unstable odd version, so when I reverted to Node version 18, these problems disappeared.
My system is macOS, and I manage packages using Homebrew. Here's what I did:
brew uninstall node
brew install node@18
After installation, since I had specified the version, I needed to set environment variables to prevent the terminal from not recognizing Node. Usually, you can get a prompt from brew after installing the program, but since I use bash, I modified the .bash_profile file and added:
export PATH="/usr/local/opt/node@18/bin:$PATH"
That's how to handle Node version issues. As for reinstalling Angular CLI, you can do the following:
npm uninstall -g @angular/cli
npm install -g @angular/cli
That should restore Angular CLI to the latest version. Good luck!
Note: It's important to keep in mind that the Node version I specified here is version 18, which was selected specifically to address the issue at this particular point in time.