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:
- https://discourse.gohugo.io/t/hugo-modules-for-dummies/20758/8
- https://discourse.gohugo.io/t/module-cache/34091/2
This may not address the problem that you are experiencing, but it’s good starting point.