js.Build throws <js>: can't evaluate field Build in type string

I am trying to get a pipeline for my js code to work, so I just wanted to get the most basic example going. I followed this simple example. This is baseof.html

<!DOCTYPE html>
   <html lang="en">
   <head>
       <meta charset="utf-8">
       <meta name="viewport" content="width=device-width, initial-scale=1">
    {{ $options := (dict "targetPath" "css/main.css") }}
    {{ $stylemain := resources.Get "scss/main.scss" | toCSS $options }}
    <link rel="stylesheet" href="{{ $stylemain.Permalink }}">
</head>
<body>
This is some test page.

{{ $built := resources.Get "js/main.js" | js.Build }}
<script src="{{ $built.RelPermalink }}"></script>
</body>
</html>

Yet on running hugo I receive the error message

Error: Error building site: failed to render pages: render of "home" failed: "/home/fridde/examplesite/layouts/_default/baseof.html:384:42": execute of template failed: template: _default/list.html:13:42: executing "_default/list.html" at <js>: can't evaluate field Build in type string

What a totally unhelpful error message. Is “js” considered to be a string? Why?

I have tried to find documentation for resources.Get and have tried to find where js.Build is defined. But since I have no experience with Go, this has been a doomed project. It doesn’t seem to be a scope problem, as similar threads have suggested.
Also, the .scss conversion to .css in the <head> works just fine without any problem.

Anyone who can point me to where things go wrong? How would you try to debug this?

What Hugo version are you using?

What, shit.

It seems like running sudo apt install hugo gives me Hugo version 0.68.3-1.

God this is annoying. I keep the post above for future reference.

So just to understand Go a little bit better: Why would the “js” in js.Build be considered a string and not just an undefined object?
It would have been much more helpful if I had gotten some error of the type “Reference to undefined object “js” on line XY”. This would have pointed me in the right direction.

Not a Go dev, so can’t answer the why.


For reference: at least Hugo v0.74 is needed.

As an update for everyone and future me: After manually updating to 0.79.1 (extended) everything works as smooth as expected.