LESS in Web Compiler for Visual Studio 2019 stopped to work

Viewed 2511

It worked for years. Yesterday for no reason (?) I'm not able to compile LESS files any more. I tried to

  • reinstall the Web Compiler extension,
  • reinstall Web Essentials 2019 extension,
  • reinstall the whole Visual Studio 2019 for 3 times,
  • start a new project from scratch

I do not know if some automatic update happened under the hoods, but basically, every time I try to compile a LESS file I get:

module.js:471
    throw err;
    ^

Error: Cannot find module 'C:\Users\igor\AppData\Local\Temp\WebCompiler1.12.394\node_modules\less\bin\lessc'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:390:7)
    at startup (bootstrap_node.js:150:9)
    at bootstrap_node.js:505:3

Thanks for any help!

3 Answers

For VS2017 and VS2019:

  • Uninstall the Web Compiler extension
  • Delete* the directory C:\Users\<username>\AppData\Local\Temp\WebCompiler1.12.394
  • Install Web Compiler

I do not know why the "lessc" file disappeared.

* From cmd.exe:

rd /S %LOCALAPPDATA%\Temp\WebCompiler1.12.394

From a PowerShell prompt:

rm -r $env:LOCALAPPDATA\Temp\WebCompiler1.12.394

How I found the solution: I attempted to re-create the .vsix file from the GitHub repository for the Web Compiler extension so that I could get the lessc file; I had installed Node.js and all its associated gubbins. Trying to use the node_modules.7z generated by build.cmd in the Web Compiler files didn't work in the end because there are several deprecated things in it - I ended up with the error described in 3.10: Breaks IE Compat Option. So I thought: oh dear, it is all broken, why not just delete the directory and try the install again?

I deleted the C:\Users\<username>\AppData\Local\Temp\WebCompiler1.12.394 folder and ran the compilation from Task Runner Explorer which recreated the folder without having to reinstall Web Compiler.

Maybe it is related to also having the BuildWebCompiler 1.12.405 NuGet package installed in the project.

I was able to fix a similar problem with a "node-sass" file missing from the Web Compiler (although the entire bin folder was empty) by performing the following actions:

  • close Visual Studio 2019
  • delete the C:\Users<username>\AppData\Local\Temp\WebCompiler1.12.394 folder
  • restart Visual Studio.

When I restarted VS, the folder was recreated with all the necessary files back where they needed to be.

When I ran into the issue I had just came back to work after taking a little over a week off. At least for me, I think a program on my computer that automatically cleans up unused temp files may have been the culprit.

Related