Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ng build --prod throwing exception #13582

Closed
fyllekanin opened this issue Feb 2, 2019 · 12 comments · Fixed by #13589
Closed

ng build --prod throwing exception #13582

fyllekanin opened this issue Feb 2, 2019 · 12 comments · Fixed by #13589

Comments

@fyllekanin
Copy link

fyllekanin commented Feb 2, 2019

🐞 Bug report

Command (mark with an x)

- [ ] new
- [x ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

No

Description

Building production for angular crashes because of Terser

🔬 Minimal Reproduction

Create a new angular app with "ng new my-app" as described on the angular.io get started
page and it will crash.

🔥 Exception or Error


`ERROR in common.162374785956ac8f24a6.js from Terser
TypeError: Cannot read property 'minify' of undefined
    at minify (C:\path\node_modules\terser-webpack-plugin\dist\minify.js:162:59)
    at module.exports (C:\path\node_modules\terser-webpack-plugin\dist\worker.js:16:41)
    at handle (C:\path\node_modules\worker-farm\lib\child\index.js:44:8)
    at process. (C:\path\node_modules\worker-farm\lib\child\index.js:51:3)
    at process.emit (events.js:182:13)
    at emit (internal/child_process.js:812:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
`

🌍 Your Environment


$ ng --version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 7.1.4
Node: 10.13.0
OS: win32 x64
Angular: 7.1.4
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.11.4
@angular-devkit/build-angular     0.11.4
@angular-devkit/build-optimizer   0.11.4
@angular-devkit/build-webpack     0.11.4
@angular-devkit/core              7.1.4
@angular-devkit/schematics        7.1.4
@ngtools/webpack                  7.1.4
@schematics/angular               7.1.4
@schematics/update                0.11.4
rxjs                              6.3.3
typescript                        3.1.6
webpack                           4.23.1

Anything else relevant?

@teogl
Copy link

teogl commented Feb 2, 2019

I have the same error.

This error is solved by installing the previous version of terser

npm install terser@3.14.1

Note: This is a temporary solution

@filipesilva
Copy link
Contributor

filipesilva commented Feb 2, 2019

This problem is related to terser/terser#251. Fix submitted in terser/terser#254 should address this.

Workaround by @sodatea in vuejs/vue-cli#3407 (comment):

For npm users: run npm i terser@3.14
For yarn users: add the following field to package.json and then rerun yarn:

"resolutions": {
  "terser": "3.14.1"
}

@johninquest
Copy link

also getting this with for the first time after updating to 7.3.0

yuriyfpmislata added a commit to WeekFood/WeekFood that referenced this issue Feb 3, 2019
@filipesilva filipesilva pinned this issue Feb 3, 2019
yuriyfpmislata added a commit to WeekFood/WeekFood that referenced this issue Feb 3, 2019
@dalibor-sanzeru
Copy link

dalibor-sanzeru commented Feb 3, 2019

FYI Provided solution with "resolution" in package.json worked on:
CLI: "@angular/cli": "^7.3.0"
ANGULAR: "@angular/common": "~7.2.3"

Problem only occurs on not-default build configurations e.g.:
ng build --configuration=staging

@hpardess
Copy link

hpardess commented Feb 4, 2019

I also face this error when I run ng build --prod --build-optimizer

[ERROR] ERROR in 0.41a9786d57a2f2254213.js from Terser
[INFO] Time: 61783ms
[ERROR] TypeError: Cannot read property 'minify' of undefined
[INFO] chunk {0} 0.41a9786d57a2f2254213.js () 47.1 kB  [rendered]

1 similar comment
@hpardess
Copy link

hpardess commented Feb 4, 2019

I also face this error when I run ng build --prod --build-optimizer

[ERROR] ERROR in 0.41a9786d57a2f2254213.js from Terser
[INFO] Time: 61783ms
[ERROR] TypeError: Cannot read property 'minify' of undefined
[INFO] chunk {0} 0.41a9786d57a2f2254213.js () 47.1 kB  [rendered]

@sysmat
Copy link

sysmat commented Feb 4, 2019

Angular CLI: 7.3.0
Node: 10.11.0
OS: win32 x64
Angular: 7.2.3
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.13.0
@angular-devkit/build-angular     0.13.0
@angular-devkit/build-optimizer   0.13.0
@angular-devkit/build-webpack     0.13.0
@angular-devkit/core              7.3.0
@angular-devkit/schematics        7.3.0
@angular/cli                      7.3.0
@ngtools/webpack                  7.3.0
@schematics/angular               7.3.0
@schematics/update                0.13.0
rxjs                              6.4.0
typescript                        3.2.4
webpack                           4.29.0

error:

ERROR in runtime.fbc6620cf651a6d9e991.js from Terser
TypeError: Cannot read property 'minify' of undefined

yuriyfpmislata added a commit to WeekFood/WeekFood that referenced this issue Feb 4, 2019
* ng new en /crud

* arreglado bug de angular CLI

angular/angular-cli#13552

* probando crear api service y hacer http

* cors para permitir al dev server de crud acceder a la api

* mas cabeceras cors & 200 para OPTIONS

* ng pruebas & cambiado origin por explicito, si no las cookies no van

* headers *

* arreglado bug de angular cli

downgrade de terser
angular/angular-cli#13582

* creado resource, buildCrud | pendiente de probar en local

* borrar dist force & build no prod

* ng router: usar hash

* env para PUERTO_API

* build-crud: buildear para local

* añadido env local en angular.json

* referirse a la nueva config en el script

* it works!

* crud -> admin & base href

* el directorio tambien xd

* unificado build-admin en build

* borrado script buildAdmin

* añadido script serve admin

* probando flujo fallo ajax

* limpieza: dejado servicio auth que ya se ajustará & a modo de ejemplo

* limpieza: resource probando delete

* newline...

* postLogin -> login

* Delete README.md
@rizrmd
Copy link

rizrmd commented Feb 4, 2019

damnnn this is breaking my build....

@FrancescoBorzi
Copy link

Same here, getting this after updating from 7.2.3 to 7.3.0

@jasedwards
Copy link

it was caused by an error in terser. There is a workaround listed in the issue but it appears they have deployed a fix a couple hours ago anyway.
terser/terser#254 (comment)

@filipesilva
Copy link
Contributor

filipesilva commented Feb 4, 2019

Hello all,

Both terser and terser-webpack-plugin have released updates that address the problem. We are in the process of updating the versions we use in #13589. This should completely prevent the bug once our fix is released.

You can force your existing projects to use the new terser version directly right now as well:

  • npm users do npm install --save terser@3.16.1 followed by npm uninstall --save terser
  • yarn users add "resolutions": { "terser": "3.16.1" } to your package.json, run yarn, then remove the resolution from package.json

ericrbaker added a commit to ericrbaker/gta-v-timer that referenced this issue Feb 6, 2019
Changing version of terser dependency since it was throwing an error during prod compilaton. See: angular/angular-cli#13582

I also realized I accidentally had a reference to a 'type' field in the car timer component, so removing that.
@filipesilva filipesilva unpinned this issue Feb 7, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants