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.

Runtime error: Cannot read property 'bind' of undefined in latest Clean-CSS 5.0

See original GitHub issue

Runtime error: Cannot read property ‘bind’ of undefined in latest Clean-CSS 5.0

Actual error stack:

Client CSS build error TypeError: Cannot read property 'bind' of undefined
  at overrideProperties (/home/vlado/dev/pigallery/node_modules/clean-css/lib/optimizer/level-2/properties/override-properties.js:468:53)
  at optimizeProperties (/home/vlado/dev/pigallery/node_modules/clean-css/lib/optimizer/level-2/properties/optimize.js:33:5)
  at reduceSelector (/home/vlado/dev/pigallery/node_modules/clean-css/lib/optimizer/level-2/reduce-non-adjacent.js:161:3)
  at reduceSimpleNonAdjacentCases (/home/vlado/dev/pigallery/node_modules/clean-css/lib/optimizer/level-2/reduce-non-adjacent.js:82:5)
  at reduceNonAdjacent (/home/vlado/dev/pigallery/node_modules/clean-css/lib/optimizer/level-2/reduce-non-adjacent.js:54:3)
  at level2Optimize (/home/vlado/dev/pigallery/node_modules/clean-css/lib/optimizer/level-2/optimize.js:89:5)
  at optimize (/home/vlado/dev/pigallery/node_modules/clean-css/lib/clean.js:221:5)
  at /home/vlado/dev/pigallery/node_modules/clean-css/lib/clean.js:194:29
  at /home/vlado/dev/pigallery/node_modules/clean-css/lib/reader/read-sources.js:26:64
  at loadOriginalSources (/home/vlado/dev/pigallery/node_modules/clean-css/lib/reader/load-original-sources.js:26:5)

Code where this happens is in clean-css/lib/optimizer/level-2/properties/override-properties.js

mayOverride = configuration[right.name].canOverride;
overridable = everyValuesPair(mayOverride.bind(null, validator), left, right);

I’ve added a debug output just to check values:

console.log('clean-css debug:', right.name, configuration[right.name], configuration[right.name].canOverride);

And for most entries it passes without errors. However, for right.name === clip, there are no defaults and property canOverride is not defined.

clean-css debug: clip {
  valueOptimizers: [
    [Function: whitespace],
    [Function: fraction],
    [Function: precision],
    [Function: unit],
    [Function: zero]
  ]
} undefined

Configuration is:

  clean = new CleanCSS({ level: { 1: { all: true }, 2: { all: true } } });

And actual CSS is at: https://github.com/vladmandic/pigallery/blob/master/client/pigallery.css

I’ve added a quick workaround with, but that’s not a solution:

  overridable = mayOverride ? everyValuesPair(mayOverride.bind(null, validator), left, right) : true;

Environment

  • Clean-CSS 5.0
  • NodeJS 15.7.0
  • OS: Ubuntu 20.10

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
vladmandiccommented, Jan 29, 2021

confirmed as resolved - thanks!

1reaction
jakubpawlowiczcommented, Jan 29, 2021

Thanks @vladmandic - the fix is ready. It was only possible to see it once files were combined, but actually the reduced test case was very very short. Going to release 5.0.1 shortly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'bind' of undefined in latest Clean-CSS ...
Runtime error : Cannot read property 'bind' of undefined in latest Clean-CSS 5.0 Actual error stack: Client CSS build error TypeError: Cannot ...
Read more >
Cannot read property 'bind' of undefined, React.js
In order to be able to bind addTimes to this in the constructor, addTimes must be a method on your class, not just...
Read more >
TypeError: Cannot read property 'bind' of undefined - Reddit
TypeError : Cannot read property 'bind' of undefined ... handleChange.bind(this); ... I'm new to React so apologies!
Read more >
cannot read properties of undefined (reading 'context')
So, it takes the value of clickedImg.id on the first render - which is undefined , because strings don't have such properties. As...
Read more >
Changelog | Meteor API Docs
Summary of breaking changes. As Node.js version was upgraded to a new major version we recommend that you review if your npm dependencies...
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