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?
Which operating system?
Have you set any Hugo environment variables?
What modules are you using?
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.
I am using macOS Monterey, Hugo is installed via homebrew
Hugo version: v0.95.0+extended darwin/amd64 BuildDate=unknown
golang version: go1.17.6 darwin/amd64
github.com/Leaflet/Leaflet v1.7.1 // indirect
github.com/Splidejs/splide v3.6.12+incompatible // indirect
github.com/dimsemenov/PhotoSwipe v4.1.4-0.20220225172002-466921877ec1+incompatible // indirect
github.com/ghosh/Micromodal v0.0.0-20220128171254-2a316150d12b // indirect
github.com/tailwindlabs/heroicons v1.0.6 // indirect
github.com/verlok/vanilla-lazyload v5.1.2-0.20220221192345-a84fec1dcf60+incompatible // indirect
after Hugo module download at random the error shown is
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.
the js error is shown in the terminal or vscode when trying to use
thanks for taking the time
This helped me with some intermittent problems…
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:
This may not address the problem that you are experiencing, but it’s good starting point.
Thank you for your prompt response, @jmooring.
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.
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.