Skip to content

Magento 2.4.8 LESS compilation error

I recently upgraded from the community edition 2.4.6 to 2.4.8.

Since updating, when running bin/magento setup:static-content:deploy I’m getting the following LESS compilation errors

Compilation from source: /vendor/magento/theme-frontend-blank/web/css/styles-l.less
error evaluating function `unit` The first argument to unit must be a number. Have you forgotten parenthesis? index: 488 in _typography.less on line 35, column 1
33| @font-size-unit-convert: true; // Controls whether font-size values are conv
erted to the specified font-size unit
34|
35| @font-size__base: unit(@font-size-unit-ratio * @font-size-ratio__base, px);
// Base font size value in <b>px</b>
36| @font-size__xl: ceil(1.5 * @font-size__base); // 21px
37| @font-size__l: ceil(1.25 * @font-size__base); // 18px
38| @font-size__s: ceil(.85 * @font-size__base); // 12px

I have tried:

  • Amending the parenthesis e.g. @font-size__base: unit(@font-size-unit-ratio * @font-size-ratio__base, px); to @font-size__base: unit((@font-size-unit-ratio * @font-size-ratio__base), px);
  • Tested the code standalone to see if a standard LESS compiler would error, and everything works and is calculated correctly.
  • Also, when using Grunt to compile the LESS files, it completes without error.

Since Grunt compiles it correctly, I’m wondering if this is due to the change to the required composer package wikimedia/less.php as this same setup worked fine before the upgrade.