If I try to test-build my application with ng build --prod --aot
I get the following, quite short, error message:
$ ng build --prod
Date: 2019-01-26T17:26:45.018Z
Hash: 979690c7a363996f24b8
Time: 28274ms
chunk {0} runtime.ea8176a0aa687d0c7546.js (runtime) 2.23 kB [entry] [rendered]
chunk {1} common.78f3e0cd7d0f774768aa.js (common) 583 bytes [rendered]
chunk {2} main.5f97cda0f273b510e26a.js (main) 973 kB [initial] [rendered]
chunk {3} polyfills.c2a7344c1c84ba3d2a73.js (polyfills) 58.2 kB [initial] [rendered]
chunk {4} styles.1094b1dd78a0fa2c8fa7.css (styles) 85 kB [initial] [rendered]
chunk {5} 5.92565e561816566c4426.js () 3.74 MB [rendered]
chunk {6} 6.a4ec6e690b75a22ddb72.js () 6.3 kB [rendered]
ERROR in 5.92565e561816566c4426.js from Terser
Unexpected token: punc ()) [5.92565e561816566c4426.js:25865,4]
No idea what's causing this. How can I fix this? Last time I checked this worked.
I have already tried rm -rf node_modules/
.
package.json
{
"name": "mz-admin",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "node server.js",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"engines": {
"node": "8.12.0",
"npm": "6.4.1"
},
"private": true,
"dependencies": {
"@agm/core": "^1.0.0-beta.3",
"@angular/animations": "7.1.0",
"@angular/cdk": "^7.1.0",
"@angular/cli": "7.0.6",
"@angular/common": "7.1.0",
"@angular/compiler": "7.1.0",
"@angular/compiler-cli": "7.1.0",
"@angular/core": "7.1.0",
"@angular/flex-layout": "^7.0.0-beta.19",
"@angular/forms": "7.1.0",
"@angular/http": "7.1.0",
"@angular/material": "^7.1.0",
"@angular/material-moment-adapter": "^7.1.0",
"@angular/platform-browser": "7.1.0",
"@angular/platform-browser-dynamic": "7.1.0",
"@angular/router": "7.1.0",
"@fortawesome/angular-fontawesome": "^0.3.0",
"@fortawesome/fontawesome-svg-core": "^1.2.4",
"@fortawesome/free-brands-svg-icons": "^5.3.1",
"@fortawesome/free-solid-svg-icons": "^5.3.1",
"@ngx-share/button": "^7.0.0",
"@ngx-share/core": "^7.0.0",
"@types/braintree-web": "^3.6.4",
"angular-mentions": "^0.8.0",
"braintree-web": "^3.41.0",
"braintree-web-drop-in": "^1.14.1",
"chart.js": "^2.7.2",
"core-js": "^2.5.7",
"express": "^4.16.3",
"http-status-codes": "^1.3.0",
"ng-pick-datetime": "^7.0.0",
"ngx-logger": "^3.1.0",
"ngx-moment": "^3.1.0",
"ngx-quill": "^4.5.0",
"paypal-checkout": "^4.0.239",
"quill": "^1.3.6",
"quill-mention": "git+https://github.com/silentsnooc/quill-mention.git",
"rxjs": "^6.3.2",
"typescript": "^3.1.6",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.10.6",
"@angular/language-service": "7.1.0",
"@types/googlemaps": "^3.30.16",
"@types/jasmine": "^3.3.0",
"@types/jasminewd2": "^2.0.6",
"@types/node": "~10.12.10",
"codelyzer": "^4.5.0",
"enhanced-resolve": "^4.1.0",
"express-http-proxy": "^1.5.0",
"jasmine-core": "~3.3.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.1.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^2.0.4",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "^5.4.1",
"ts-node": "~7.0.1",
"tslint": "^5.11.0",
"webpack-bundle-analyzer": "^3.0.3"
}
}
Part of the build log
[1m[33mWARNING in Terser Plugin: Dropping unused variable template [6.a4ec6e690b75a22ddb72.js:136,12][39m[22m
[1m[33mWARNING in Terser Plugin: Dropping unused variable routes [6.a4ec6e690b75a22ddb72.js:148,4][39m[22m
[1m[31mERROR in 5.92565e561816566c4426.js from Terser
Unexpected token: punc ()) [5.92565e561816566c4426.js:25865,4][39m[22m
Child [1mmini-css-extract-plugin node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!node_modules/postcss-loader/src/index.js??extracted!node_modules/sass-loader/lib/loader.js??ref--14-3!src/styles.scss[39m[22m:
[1mAsset[39m[22m [1mSize[39m[22m [1mChunks[39m[22m [1m[39m[22m[1m[39m[22m[1mChunk Names[39m[22m
[1m[32m3rdpartylicenses.txt[39m[22m 1 bytes [1m[39m[22m [1m[32m[39m[22m
Entrypoint [1mmini-css-extract-plugin[39m[22m = [1m[32m*[39m[22m
chunk {[1m[33m0[39m[22m} [1m[32m*[39m[22m (mini-css-extract-plugin) 102 KiB[1m[33m [entry][39m[22m[1m[32m [rendered][39m[22m
Child [1mmini-css-extract-plugin node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!node_modules/postcss-loader/src/index.js??extracted!node_modules/sass-loader/lib/loader.js??ref--14-3!src/theme.scss[39m[22m:
[1mAsset[39m[22m [1mSize[39m[22m [1mChunks[39m[22m [1m[39m[22m[1m[39m[22m[1mChunk Names[39m[22m
[1m[32m3rdpartylicenses.txt[39m[22m 1 bytes [1m[39m[22m [1m[32m[39m[22m
Entrypoint [1mmini-css-extract-plugin[39m[22m = [1m[32m*[39m[22m
chunk {[1m[33m0[39m[22m} [1m[32m*[39m[22m (mini-css-extract-plugin) 55.6 KiB[1m[33m [entry][39m[22m[1m[32m [rendered][39m[22m
WARNING in Terser Plugin: global_defs ngDevMode redefined [main.5f97cda0f273b510e26a.js:14309,21]
WARNING in Terser Plugin: global_defs ngDevMode redefined [main.5f97cda0f273b510e26a.js:14510,25]
WARNING in Terser Plugin: global_defs ngDevMode redefined [main.5f97cda0f273b510e26a.js:15652,21]
WARNING in Terser Plugin: global_defs ngDevMode redefined [main.5f97cda0f273b510e26a.js:15658,21]
With --source-map
$ ng build --prod --aot --source-map
Date: 2019-01-26T22:31:44.106Z
Hash: 51afc4cc158a10e520c6
Time: 45390ms
chunk {0} runtime.b29d49d6f279fff34f57.js, runtime.b29d49d6f279fff34f57.js.map (runtime) 2.29 kB [entry] [rendered]
chunk {1} common.70409de1782336a79716.js, common.70409de1782336a79716.js.map (common) 639 bytes [rendered]
chunk {2} main.01e8ea6a2dd33c4e19d8.js, main.01e8ea6a2dd33c4e19d8.js.map (main) 970 kB [initial] [rendered]
chunk {3} polyfills.22294cd4941de9604b91.js, polyfills.22294cd4941de9604b91.js.map (polyfills) 61.7 kB [initial] [rendered]
chunk {4} styles.97ca4c55e9ba593fdf4c.css, styles.97ca4c55e9ba593fdf4c.css.map (styles) 85.5 kB [initial] [rendered]
chunk {5} 5.33da963a3dd6decc5efc.js, 5.33da963a3dd6decc5efc.js.map () 1.9 MB [rendered]
chunk {6} 6.85bd192b02e86745d878.js, 6.85bd192b02e86745d878.js.map () 6.35 kB [rendered]
Without --source-map
$ ng build --prod --aot
Date: 2019-01-26T22:32:18.173Z
Hash: b5bcaa2123bb6718baf2
Time: 28403ms
chunk {0} runtime.0935b498984fda7c2e4f.js (runtime) 2.23 kB [entry] [rendered]
chunk {1} common.78f3e0cd7d0f774768aa.js (common) 583 bytes [rendered]
chunk {2} main.2ae834dcaf8208d7aecd.js (main) 970 kB [initial] [rendered]
chunk {3} polyfills.588b345e325a2549098e.js (polyfills) 61.7 kB [initial] [rendered]
chunk {4} styles.088d5b7a7a0995d1df55.css (styles) 85.4 kB [initial] [rendered]
chunk {5} 5.7e99fa00323b77c4e1c2.js () 3.82 MB [rendered]
chunk {6} 6.954a4978d0c6c411bb2f.js () 6.3 kB [rendered]
ERROR in 5.7e99fa00323b77c4e1c2.js from Terser
Unexpected token: punc ()) [5.7e99fa00323b77c4e1c2.js:27338,4]
With --source-map --named-chunks
$ ng build --prod --source-map --named-chunks
Date: 2019-01-26T23:00:18.699Z
Hash: c37b8f2ccfedbbf077fa
Time: 61888ms
chunk {0} runtime.a670ad696846ba781d64.js, runtime.a670ad696846ba781d64.js.map (runtime) 2.37 kB [entry] [rendered]
chunk {1} common.d7fbf062c6d87ac4ade2.js, common.d7fbf062c6d87ac4ade2.js.map (common) 639 bytes [rendered]
chunk {2} component-application-application-module-ngfactory.22de247f215039a3cf63.js, component-application-application-module-ngfactory.22de247f215039a3cf63.js.map (component-application-application-module-ngfactory) 1.9 MB [rendered]
chunk {3} main.2897da054822ebda9646.js, main.2897da054822ebda9646.js.map (main) 973 kB [initial] [rendered]
chunk {4} module-embedding-calendar-calendar-module-ngfactory.5b0025d2f887a5d7b22d.js, module-embedding-calendar-calendar-module-ngfactory.5b0025d2f887a5d7b22d.js.map (module-embedding-calendar-calendar-module-ngfactory) 6.4 kB [rendered]
chunk {5} polyfills.04ae14cfab6dbb09ad49.js, polyfills.04ae14cfab6dbb09ad49.js.map (polyfills) 61.7 kB [initial] [rendered]
chunk {6} styles.52c1571339895f2464fa.css, styles.52c1571339895f2464fa.css.map (styles) 85.5 kB [initial] [rendered]
It seems that
ng build --prod --named-chunks --verbose --build-optimizer=false --source-map
finally does the trick - with this, I am finally getting the source of the error:
ERROR in component-application-application-module-ngfactory.7eb30a010bb7783ce652.js from Terser
Unexpected token: punc ()) [./node_modules/quill-mention/src/quill.mention.js:183,0][component-application-application-module-ngfactory.7eb30a010bb7783ce652.js:29528,4]
It all started with this warning:
It was this missing comma, which I put there to silence the warning, which rendered my project uncompileable.
I was only able to locate this issue by using --source-map
but also setting --build-optimizer=false
ng build --prod --named-chunks --verbose --build-optimizer=false --source-map
After upgrading to angular 8 during production build, I was getting "Error in common-es2015.xxx.js from Terser Unexpected token: Punc(;) [common-es2015.xxx.js] "
After setting sourceMap to true in angular.json file - configurations- production section, compiler displayed actual file name with error line number. It was due to an extra semicolon in a variable declaration in the class file.
putGamma: any = 0.0;;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With