Solvedangular cli Halting Problem at 95%. Shows emitting as the action doing.

I was hit by a problem like halting problem of truing machine while using the angular cli as follows.
My script : node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng build -e=prod --prod --sourcemap --vendor-chunk=true --build-optimizer


Angular CLI: 1.7.3
Node: 9.8.0
OS: win32 x64
Angular: 5.2.8
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router

@angular/cli: 1.7.3
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.4.0
webpack-bundle-analyzer: 2.11.1

Repro steps

Use this script : node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng build -e=prod --prod --sourcemap --vendor-chunk=true --build-optimizer --stats-json

  • Apply the above script to any angular project.
  • If we replace --scourcemap with --no-souecemap the problem will not comes.

Observed behavior

The program is running indefinitely.

Desired behavior

The program should halt to say if there is some error in the script.

45 Answers

✔️Accepted Answer

In my case, the problem was solved by updating devkit package
ng update @angular-devkit/build-angular

Other Answers:

Why is this issue closed? On Angular/CLI 6.1.1 the issue still occurs when I have optimization enabled @hansl ?

Turns out the reason my initial repro did not work was because the component CSS needed to have some content, not only exist.

So having some basic CSS on src/app/app.component.css like:

h1 {
  background-color: #000;

On a starter project and running ng build --aot --optimization --source-map will always reproduce the problem.

Changing that to a .scss file like @hahn-kev mentioned will make the bug go away.

So now we know that it's definitely related to CSS files specifically and content is needed to reproduce.

I am experiencing this too with 1.7.3 on Windows 10. Build finishes normally if I remove --sourcemaps from parameters.

Why it hangs at 95%?

On webpack Compiler.js, method emitAssets(), a badly formed directory name is passed (the drive letter included twice) to mkdirp. It hangs because of [0]. It looks like it's an issue only on Windows.

What makes it hang?

Indeed the source maps for the styleUrls. Unlike the js files, these css files are referenced by the full path. I guess previously they weren't generated. I'm not sure exactly what to make of those, but extracting a relative path might help. I'm curious how is the output on non-Windows platforms.

// need to call this on mkdirp and writeFile
const relativePath = makePathsRelative(this.context, targetFile);

I'd say it's okay to not generate for production builds. I don't think they are useful.

@filipesilva how to proceed with this fix? This is a show stopper for v6.x for Windows users.

[0] substack/node-mkdirp#125

More Issues: