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 build --prod fails with "ERROR in xx.js from Terser undefined" after upgrade to Angular 7

See original GitHub issue

I am upgrading Angular 5 to Angular 7. ng build looks good but ng build with --prod flag fails with ERROR in xx.js from Terser undefined. I checked the issue 12662 but didn’t find tether npm package in my project. Now I am adding terser latest version 3.10.12 but still getting the same error.

Versions

I am using node version v11.3.0 on Ubuntu 16 Those are the dependencies in package.json

 "dependencies": {
    "@angular/animations": "7.1.1",
    "@angular/cdk": "^7.1.0",
    "@angular/common": "7.1.1",
    "@angular/compiler": "7.1.1",
    "@angular/core": "7.1.1",
    "@angular/forms": "7.1.1",
    "@angular/http": "7.1.1",
    "@angular/material": "^7.1.0",
    "@angular/platform-browser": "7.1.1",
    "@angular/platform-browser-dynamic": "7.1.1",
    "@angular/router": "7.1.1",
    "@ngx-translate/core": "^11.0.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "@types/underscore": "^1.8.7",
    "angulartics2": "^7.2.0",
    "core-js": "^2.4.1",
    "hammerjs": "^2.0.8",
    "npm": "^6.4.1",
    "rxjs": "^6.3.3",
    "rxjs-compat": "^6.3.3",
    "terser": "^3.10.12",
    "tslib": "^1.9.0",
    "underscore": "^1.8.3",
    "uninstall": "0.0.0",
    "yaml-js": "^0.2.3",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.11.0",
    "@angular/cli": "7.1.0",
    "@angular/compiler-cli": "7.1.1",
    "@angular/language-service": "7.1.1",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~9.6.5",
    "codelyzer": "^4.0.1",
    "jasmine-core": "^3.2.1",
    "jasmine-spec-reporter": "^4.2.1",
    "karma": "^3.0.0",
    "karma-cli": "^1.0.1",
    "karma-coverage-istanbul-reporter": "^2.0.3",
    "karma-jasmine": "^1.1.2",
    "karma-jasmine-html-reporter": "^1.3.1",
    "protractor": "^5.4.1",
    "ts-node": "~6.0.0",
    "tslint": "^5.11.0",
    "typescript": "3.1.6"
  }

Those are terser related packages in package-lock.json

 "terser": {
      "version": "3.10.12",
      "resolved": "https://registry.npmjs.org/terser/-/terser-3.10.12.tgz",
      "integrity": "sha512-3ODPC1eVt25EVNb04s/PkHxOmzKBQUF6bwwuR6h2DbEF8/j265Y1UkwNtOk9am/pRxfJ5HPapOlUlO6c16mKQQ==",
      "requires": {
        "commander": "~2.17.1",
        "source-map": "~0.6.1",
        "source-map-support": "~0.5.6"
      },
      "dependencies": {
        "commander": {
          "version": "2.17.1",
          "resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz",
          "integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg=="
        },
        "source-map": {
          "version": "0.6.1",
          "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
          "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
        },
        "source-map-support": {
          "version": "0.5.9",
          "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.9.tgz",
          "integrity": "sha512-gR6Rw4MvUlYy83vP0vxoVNzM6t8MUXqNuRsuBmBHQDu1Fh6X015FrLdgoDKcNdkwGubozq0P4N0Q37UyFVr1EA==",
          "requires": {
            "buffer-from": "^1.0.0",
            "source-map": "^0.6.0"
          }
        }
      }
    },
    "terser-webpack-plugin": {
      "version": "1.1.0",
      "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.1.0.tgz",
      "integrity": "sha512-61lV0DSxMAZ8AyZG7/A4a3UPlrbOBo8NIQ4tJzLPAdGOQ+yoNC7l5ijEow27lBAL2humer01KLS6bGIMYQxKoA==",
      "dev": true,
      "requires": {
        "cacache": "^11.0.2",
        "find-cache-dir": "^2.0.0",
        "schema-utils": "^1.0.0",
        "serialize-javascript": "^1.4.0",
        "source-map": "^0.6.1",
        "terser": "^3.8.1",
        "webpack-sources": "^1.1.0",
        "worker-farm": "^1.5.2"
      },
      "dependencies": {
        "find-cache-dir": {
          "version": "2.0.0",
          "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-2.0.0.tgz",
          "integrity": "sha512-LDUY6V1Xs5eFskUVYtIwatojt6+9xC9Chnlk/jYOOvn3FAFfSaWddxahDGyNHh0b2dMXa6YW2m0tk8TdVaXHlA==",
          "dev": true,
          "requires": {
            "commondir": "^1.0.1",
            "make-dir": "^1.0.0",
            "pkg-dir": "^3.0.0"
          }
        },
        "find-up": {
          "version": "3.0.0",
          "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz",
          "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==",
          "dev": true,
          "requires": {
            "locate-path": "^3.0.0"
          }
        },
        "locate-path": {
          "version": "3.0.0",
          "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz",
          "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==",
          "dev": true,
          "requires": {
            "p-locate": "^3.0.0",
            "path-exists": "^3.0.0"
          }
        },
        "p-limit": {
          "version": "2.0.0",
          "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.0.0.tgz",
          "integrity": "sha512-fl5s52lI5ahKCernzzIyAP0QAZbGIovtVHGwpcu1Jr/EpzLVDI2myISHwGqK7m8uQFugVWSrbxH7XnhGtvEc+A==",
          "dev": true,
          "requires": {
            "p-try": "^2.0.0"
          }
        },
        "p-locate": {
          "version": "3.0.0",
          "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz",
          "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==",
          "dev": true,
          "requires": {
            "p-limit": "^2.0.0"
          }
        },
        "p-try": {
          "version": "2.0.0",
          "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.0.0.tgz",
          "integrity": "sha512-hMp0onDKIajHfIkdRk3P4CdCmErkYAxxDtP3Wx/4nZ3aGlau2VKh3mZpcuFkH27WQkL/3WBCPOktzA9ZOAnMQQ==",
          "dev": true
        },
        "pkg-dir": {
          "version": "3.0.0",
          "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz",
          "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==",
          "dev": true,
          "requires": {
            "find-up": "^3.0.0"
          }
        },
        "source-map": {
          "version": "0.6.1",
          "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
          "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
          "dev": true
        }
      }
    },

Also ng build --prod always stuck on 92% chunk asset optimization TerserPlugin for 1 minute. Not sure if it is related.

Does someone have any idea? Thanks.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
AudrenThibaultcommented, Apr 18, 2019

Hello, I also have this problem after ng build --prod except that it’s not “undefined”.

this is the error :
“ERROR in scripts.e76817c8d2c56b2cd376.js from Terser Invalid assignment [scripts.e76817c8d2c56b2cd376.js:21,32]”

I tryed your solution @immad-hamid but it didn’t work for me…

2reactions
immad-hamidcommented, Feb 4, 2019

@mengzhen94 I have found the fix, it’s due to terser. If terser exist in your package.json file then downgrade it to “terser”: “3.14.1” without ^ and if you don’t see it in your package.json then it must be in package.lock.json, in this case do as follow:

Just add “terser”: “3.14.1” in your devDependencies in your package.json and npm install. You now would be able to make a production build without any issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular - Error In Runtime From Terser During Build --prod
It seems to be a problem with the recently released version 3.16 of Terser, here's the related issue in Terser and in Terser...
Read more >
Debugging Story: Build failed, error from Terser - Tan Li Hau
It all started with an error message during the build: 'ERROR in bundle.xxx.js from Terser'.
Read more >
Angular V9 Build --Prod Fail , Terser - ADocLib
js from Terser with Invalid assignment error. Problem. I created a single-spa-angular app using following commands and updated it to Angular 9.0.7. ng...
Read more >
angular/angular-cli - Gitter
Can someone help me with 'ng build --prod' problem? I'm tryin' to build project, but this error occurs: TypeError: Cannot read property 'kind'...
Read more >
ineffective mark-compacts near heap limit allocation failed angular ...
Most times when you face this error it's probably because of a memory leak, an addition/version upgrade of a library or a difference...
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