I have a .less file that contains a few definitions that make use of variables that are defined in another file.
Example:
body {
font-family: @baseFontFamily;
font-size: @baseFontSize;
color: @textColor;
}
Initially, IntelliJ showed the variables as undefined. When I compiled with Lessc I’d get an error that read as such:
TypeError: Cannot call method ‘charAt’ of undefined
at getLocation (C:\PATH\npm\node_modules\less\lib\less\parser.js:212:34)
at new LessError (C:\PATH\npm\node_modules\less\lib\less\parser.js:221:19)
at Object.toCSS (C:\PATH\npm\node_modules\less\lib\less\parser.js:385:31)
at C:\PATH\npm\node_modules\less\bin\lessc:107:28
at C:\PATH\npm\node_modules\less\lib\less\parser.js:434:40
at C:\PATH\npm\node_modules\less\lib\less\parser.js:94:48
at C:\PATH\npm\node_modules\less\lib\less\index.js:116:17
at C:\PATH\npm\node_modules\less\lib\less\parser.js:434:40
at C:\PATH\npm\node_modules\less\lib\less\parser.js:94:48
at C:\PATH\npm\node_modules\less\lib\less\index.js:116:17
After doing a little reading I determined that this means there is an error somewhere up in my code. I naturally assumed it was due to the variable definition not working. I commented the lines with variables out, and lessc would compile my project fine.
However, even after I added the appropriate @import so that the variables were defined (and the lines with variables uncommented), I again received the compile-time error. Is there something I’m missing?
Issue discovered. There was ‘config.less’ file in the parent and child folders. Moving the contents of the config.less from the child to the parent version solved the issues I was experiencing.