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.
1 Answer 1
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
Try enclose your math operations to a () as shown above.
-
Unfortunately this does not work. As I put in my original question, this was the first thing that was 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);Owen– Owen2025年07月30日 08:16:02 +00:00Commented Jul 30 at 8:16 -
Sorry it didn't help. I assume you have cleared the static and var/view_processed files befor running static-content deploy again? This solution works on my end and it took me a lifetime identifying this errors.Zedek Deo Mero– Zedek Deo Mero2025年08月04日 03:47:02 +00:00Commented Aug 4 at 3:47
Explore related questions
See similar questions with these tags.
unitThe first argument to unit must be a number. Have you forgotten parenthesis? index: 1088 in _typography.less on line 32, column 1 30| 31| @font-size-unit: rem; // The unit to which most typography values will be converted by default 32| @font-size-unit-ratio: unit(@root__font-size * 16/100); // Ratio of the root font-size to the font-size unit 33| @font-size-unit-convert: true; // Controls whether font-size values are converted to the specified font-size unit 34| 35| @font-size__base: unit(@funitThe first argument to unit must be a number. Have you forgotten parenthesis? index: 1085 in _typography.less on line 32, column 1 30| 31| @font-size-unit: rem; // The unit to which most typography values will be converted by default 32| @font-size-unit-ratio: unit(@root__font-size * 16/100); // Ratio of the root font-size to the font-size uni