My dislike [of Hugo modules] is limited to a single very specific Hugo module issue. I’ve wasted way too much time hunting for js issues only to discover that I need to run hugo mod clean.
This random download and deceptive error caused a lot of frustration and wasted time. Is there a way to figure out why Hugo downloads modules at random, and why the error message indicates a JS error instead of prescribing hugo mod clean?
Seeing the public repos for the modules (or at least the configuration of the modules, as well as the config of the module consumer) would make it much easier to look at what is going on.
It ‘shouldn’t’ matter if you do module clean (except during development, when modules are changing) in normal circumstances.
Also the JS error; is this in the browser? That would indicate to me that wrong version of module has been used of some component has been imported.
after Hugo module download at random the error shown is js.Build failed
1st time took me many hours trying to find why js.build failed then I realise it might happen due to auto module download by Hugo. using hugo mod clean fix the js.Build failed error. It happens at random when running Hugo or Hugo server.
On Linux the default cache directory is /tmp/hugo_cache. This is a volatile location, cleared on reboot. I think the same is true on the Mac.
Set the HUGO_CACHEDIR environment variable to something other than the system temporary directory, but make sure that it is outside of your project path. Related comments:
I believe this will solve the problem, unlike node modules, which downloads and stores all files in the Hugo project, Hugo modules only utilize those files temporarily (correct me if I’m wrong) and do not keep them in the project permanently.
Mac’s security and performance program clears temporary files in order to optimize the Mac’s performance. Because the modules are no longer available, this causes them to re download. I think I have it now
This would benefit new Hugo module users if Hugo could identify the module download and advise running Hugo mod clean after an unsuccessful build.