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.

1.5.1 build-optimizer "TypeError: candidate.value.definition is not a function"

See original GitHub issue

Versions

Angular CLI: 1.5.1
Node: 6.11.4
OS: win32 x64
Angular: 5.0.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, service-worker

@angular/cdk: 5.0.0-rc0
@angular/cli: 1.5.1
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.36
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.1
@schematics/angular: 0.1.5
typescript: 2.4.2
webpack: 3.8.1

Repro steps

  • run ng build --prod
  • don’t know what this could be related to, since my project is quite large

Observed behavior

ERROR in main.c625bf1271eaaf6ccac7.bundle.js from UglifyJs
TypeError: candidate.value.definition is not a function
    at collapse (eval at <anonymous> (C:\github\web\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:1:0), <anonymous>:8275:61)
    at tighten_body (eval at <anonymous> (C:\github\web\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:1:0), <anonymous>:8110:17)
    at eval (eval at <anonymous> (C:\github\web\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:1:0), <anonymous>:12402:9)
    at AST_Node.eval [as optimize] (eval at <anonymous> (C:\github\web\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:1:0), <anonymous>:7481:23)
    at Object.before (eval at <anonymous> (C:\github\web\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:1:0), <anonymous>:7464:24)
    at AST_Node.eval [as transform] (eval at <anonymous> (C:\github\web\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:1:0), <anonymous>:4559:35)
    at eval (eval at <anonymous> (C:\github\web\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:1:0), <anonymous>:4688:43)
    at Object.before (eval at <anonymous> (C:\github\web\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:1:0), <anonymous>:7459:9)
    at AST_Node.eval [as transform] (eval at <anonymous> (C:\github\web\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:1:0), <anonymous>:4559:35)
    at eval (eval at <anonymous> (C:\github\web\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:1:0), <anonymous>:4679:43)
    at Object.before (eval at <anonymous> (C:\github\web\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:1:0), <anonymous>:7459:9)
    at AST_Node.eval [as transform] (eval at <anonymous> (C:\github\web\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:1:0), <anonymous>:4559:35)
    at eval (eval at <anonymous> (C:\github\web\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:1:0), <anonymous>:4590:31)
    at Object.before (eval at <anonymous> (C:\github\web\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:1:0), <anonymous>:7459:9)
    at AST_Node.eval [as transform] (eval at <anonymous> (C:\github\web\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:1:0), <anonymous>:4559:35)
    at eval (eval at <anonymous> (C:\github\web\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:1:0), <anonymous>:4578:25)

It worked with 1.5.0 with --build-optimizer and works with 1.5.1 when specifying --build-optimizer=false.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
filipesilvacommented, Nov 26, 2017

@kzc awesome, thank you!

For users affected by this problem, here is how you can force your dependencies to use the uglify-es@3.2.0.

You can’t just add it as a dependency with a new version since the uglify-es is not a direct dependency.

To see what version you have, run npm list uglify-es:

$ npm list uglify-es
master-project@0.0.0 D:\sandbox\master-project
`-- @angular/cli@1.5.3
  `-- uglifyjs-webpack-plugin@1.0.0
    `-- uglify-es@3.1.5

To force an indirect dependency to use a new version, you’ll have to update your cache and remove the any package-locks you have. This series of commands should do it:

// Force update your cache
npm install uglify-es@3.2.0
npm uninstall uglify-es@3.2.0
// Remove node modules and package locks
rm -rf node_modules package-lock.json yarn.lock
// Reinstall dependencies
npm install

After all of this, you should be able to see the new version:

$ npm list uglify-es
master-project@0.0.0 D:\sandbox\master-project
`-- @angular/cli@1.5.3
  `-- uglifyjs-webpack-plugin@1.0.0
    `-- uglify-es@3.2.0

I realize this process is cumbersome. NPM does not offer a good way to force update indirect dependencies.

I’ve submitted a PR to update our direct dependency (uglifyjs-webpack-plugin): https://github.com/webpack-contrib/uglifyjs-webpack-plugin/pull/176.

Then Angular CLI can update to that version and everyone gets the new version of uglify-es by default.

1reaction
kzccommented, Nov 21, 2017

The bug is present in both branches - latest uglify-es@3 and uglify-js@3.

You might try using an older version of uglify-es in your npm or yarn lock file.

Read more comments on GitHub >

github_iconTop Results From Across the Web

candidate.toLowerCase is not a function. (In ... - Stack Overflow
getOptionLabel should return string while top100Films.year returns a number. change the getOptionLabel as below and it'll work fine:
Read more >
[Autocomplete] candidate.toLowerCase is not a function #23572
The issue is present in the latest release. I have searched the issues of this repository and believe that this is not a...
Read more >
How to fix "Uncaught TypeError: x is not a function" in JavaScript
JS Casts 01 - How to fix "Uncaught TypeError : x is not a function " in JavaScript.Visit https://javascriptcasts.com/episodes/01 for a summary ...
Read more >
Uncaught TypeError | Is Not A Function | Solution - YouTube
Have you encountered an error like:- Uncaught TypeError - Some selector is not a function - jQuery is not a function - owlCarousel...
Read more >
v2.24.1 PDF - MMDetection's documentation!
rate will be automatically scaled base on this value when the batch size is 16. Meanwhile, in order not to affect other.
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