Search code examples
reactjswebpacklessantd

Less error: "Operation on an invalid type" in antd dependency


I have a react-scripts app that uses Antd controls. I'm trying to update some dependencies, and now I'm getting the error when I build:

Failed to compile.

position: absolute; top: 8px + @font-size-base * @line-height-base / 2 - @font-size-base / 2;
^ Operation on an invalid type Error in <...>/node_modules/antd/lib/alert/style/index.less (line 29, column 4)

I am using react-scripts 5.0.1, less-loader 11.0.0, less 4.1.3, node 16, webpack 5.74.0. Any ideas on how to debug this? The code in antd seems to be valid and I see the variables being defined in the index file.


Solution

  • Set math as always in your less options

    math: 'always'

    Credits here