4

After updating to Angular 15, my build process

"build:project:prod": "ng build project --configuration prod --stats-json=true --single-bundle=true && npm run copyAssets"

didn't exit after the build, so copyAssets don't even start. In a terminal, I see a table with a chunk file and a line

Build at: 2023-02-03T15:44:54.029Z - Hash: 5837a5d758832c93 - Time: 7163ms

The whole pipeline is broken down because of it. How can I ensure that the whole script is executed properly?

E1dar
  • 575
  • 1
  • 7
  • 15
  • The same problem is happening to me. Although for me, the build does finish; it just takes a long time. `ng build` says it produces its output in a couple of seconds, but then it doesn't end the process for four more minutes. No output, even with the `--verbose` flag. Still investigating. – Tyler Mumford Feb 23 '23 at 05:55
  • 1
    What version of Node is being used? I was having this problem with 19, but I switched to 18 (the LTS version) and the commands now exit properly. (It wasn't just a problem with `ng build`; it was every command. Even simple ones like `ng version`.) – Tyler Mumford Feb 23 '23 at 07:33
  • `ng analytics disable --global` seems to fix the problem for me – SmallhillCZ Apr 18 '23 at 15:16

2 Answers2

2

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.

Pork Jackson
  • 339
  • 1
  • 15
0

Try run it in steps, like first just de build: ng build project --configuration prod, after se single bundling and so one, in this way maybe you could find out where it is blocked.

Zsolt Balint
  • 767
  • 1
  • 6