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 serve --prod Cannot use [chunkhash] or [contenthash]

See original GitHub issue

Versions

Angular CLI: 6.0.0-rc.5
Node: 8.9.1
OS: win32 x64
Angular: 6.0.0-rc.5
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.5.7
@angular-devkit/build-angular     0.5.7
@angular-devkit/build-optimizer   0.5.7
@angular-devkit/core              0.5.7
@angular-devkit/schematics        0.5.7
@ngtools/json-schema              1.2.0
@ngtools/webpack                  6.0.0-rc.5
@schematics/angular               0.5.7
@schematics/update                0.5.7
rxjs                              6.0.0-uncanny-rc.7
typescript                        2.7.2
webpack                           4.5.0

Repro steps

  • Set “hmr”: true under serve options
  • ng serve --prod

Observed behavior

****************************************************************************************

Date: 2018-04-20T11:18:32.210Z
Hash: 479da56e19191460642b
Time: 25039ms
chunk {0} admin-admin-module-ngfactory.2293166986b2fdeaaf9e.js (admin-admin-module-ngfactory) 811 bytes  [rendered]
chunk {1}  (runtime) [entry] [rendered]
chunk {2} styles.34c57ab7888ec1573f9c.css (styles) 0 bytes [initial] [rendered]
chunk {3} polyfills.fbe8aa029ddbd67561f0.js (polyfills) 59.4 kB [initial] [rendered]
chunk {4} main.272e4975a98129fc0e4c.js (main) 382 kB [initial] [rendered]

ERROR in chunk runtime [entry]
[name].[chunkhash:20].js
Cannot use [chunkhash] or [contenthash] for chunk in '[name].[chunkhash:20].js' (use [hash] instead)

Desired behavior

No error

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:10
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
alan-agius4commented, Jan 2, 2019

Yes, this is still reproducible with 7.1.2, which is sort of indented since using the chunkhash would break HMR.

There are two possible fixes for this.

  1. If using hmr with outputHashing we display an appropiate error that states that these 2 options cannot be used together.
  2. If running under HMR, we change the contenthash and chunkhash to hash. in https://github.com/angular/angular-cli/blob/2326850374cd393a825e339beb5846afcff87f8a/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/utils.ts#L32-L33
3reactions
billdwhitecommented, May 7, 2018

I was able to get around this by setting “outputHashing”: “none” in my angular.json file. I’m not entirely clear on how that works anyway but it allowed me to keep working until this gets resolved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot use [chunkhash] or [contenthash] for chunk in '[name ...
Very useful because I forgot to remove --hmr when trying a production mode build on local development server ( ng serve --prod --hmr...
Read more >
ERROR in chunk application [entry] js/[name]-[contenthash].js ...
I have always this error in red !!! ERROR in chunk application [entry] js/[name]-[contenthash].js Cannot use [chunkhash] or [contenthash] for ...
Read more >
Angular CLI v11.0.3 Release - GitClear
ng serve --prod Cannot use [chunkhash] or [contenthash] · #10411 · angular-cli 11's scss source map only shows the file listed in angular....
Read more >
How to configure Webpack 4 with Angular 7: a complete guide
[contenthash] returns a hash generated based on content. It's preferable to use particularly hash and chunkhash only for production as hashing ...
Read more >
webpack/webpack - Gitter
Cannot use import statement outside a module import Swiper from 'swiper'; ... stuff will need to end up in a location that the...
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