htnabe
October 23, 2026, 2:15pm
1
I encountered a js.Build regression after upgrading Hugo from 0.166.0 to 0.168.0 (Homebrew, Linux amd64).
A dependency uses require(‘./util.inspect’) and maps “./util.inspect.js” to false in its package.json browser field. Although util.inspect.js exists, Hugo fails with:
lstat .../node_modules/object-inspect/util.inspect: no such file or directory
I reproduced this without a theme or external npm dependencies:
Hugo 0.166.0: succeeds.
Hugo 0.168.0: fails.
Hugo 0.168.0 with an explicit .js extension in the require: succeeds.
The minimal reproduction and results are in this GitHub issue:
opened 02:10PM - 23 Oct 26 UTC
### What version of Hugo are you using (`hugo version`)?
<pre>
$ hugo version
h… ugo v0.168.0+extended+withdeploy linux/amd64 BuildDate=2026-10-13T16:42:50Z VendorInfo=Homebrew
</pre>
OS/architecture: Linux amd64. Installed with Homebrew.
### Does this issue reproduce with the latest release?
Yes, with v0.168.0, the latest release at the time of reporting.
The same minimal reproduction succeeds with v0.166.0:
```text
hugo v0.166.0-78400b4de8adc99273d3e674ed6c4d14c3bdf669+extended linux/amd64 BuildDate=2026-09-09T14:45:02Z VendorInfo=gohugoio
```
### Summary
`js.Build` fails when a dependency uses an extensionless CommonJS `require` that is disabled by a `browser` field mapping to `false`.
The target `.js` file exists. However, Hugo reports `lstat .../util.inspect: no such file or directory` for the extensionless path instead of allowing esbuild to produce the disabled module stub.
This reproduces without any theme, content, external npm installation, or custom security settings.
### Minimal reproduction
Run the following in an empty directory. The small package under `node_modules` is a synthetic fixture, not an installed dependency.
```sh
mkdir -p assets layouts node_modules/browser-disabled-repro
cat > hugo.toml <<'EOF'
baseURL = "https://example.org/"
disableKinds = ["taxonomy", "term", "rss", "sitemap"]
EOF
cat > layouts/index.html <<'EOF'
{{ $js := resources.Get "main.js" | js.Build }}
<script src="{{ $js.RelPermalink }}"></script>
EOF
cat > assets/main.js <<'EOF'
import value from "browser-disabled-repro";
console.log(value);
EOF
cat > node_modules/browser-disabled-repro/package.json <<'EOF'
{
"name": "browser-disabled-repro",
"version": "1.0.0",
"main": "index.js",
"browser": {
"./util.inspect.js": false
}
}
EOF
cat > node_modules/browser-disabled-repro/index.js <<'EOF'
module.exports = require("./util.inspect");
EOF
cat > node_modules/browser-disabled-repro/util.inspect.js <<'EOF'
module.exports = "This file must be excluded from browser builds.";
EOF
hugo --noBuildLock
```
### Actual result
On v0.168.0 the build exits with code 1. Relevant error excerpt (absolute project path normalized):
```text
error calling RelPermalink: JSBUILD: failed to transform "/main.js" (text/javascript): lstat /path/to/repro/node_modules/browser-disabled-repro/util.inspect: no such file or directory
```
### Expected result
The build should succeed, with the dependency replaced by an empty browser module according to `browser: { "./util.inspect.js": false }`, without including the excluded file's content.
### Comparison and control
| Configuration | Result |
| --- | --- |
| v0.166.0, `require("./util.inspect")` | Build succeeds, exit 0 |
| v0.168.0, `require("./util.inspect")` | Build fails with the `lstat` error, exit 1 |
| v0.168.0, changing only the require to `require("./util.inspect.js")` | Build succeeds, exit 0 |
The v0.166.0 output explicitly contains a disabled-module stub:
```js
// (disabled):node_modules/browser-disabled-repro/util.inspect
var require_util = __commonJS({
"(disabled):node_modules/browser-disabled-repro/util.inspect"() {
}
});
```
The explicit-extension control is only diagnostic; it is not a proposed fix for third-party dependencies.
### Possibly related change
Commit https://github.com/gohugoio/hugo/commit/2aa51f3485054bca4a2e368bed4be32367b229e6 adds an `OnLoad` hook in the `file` namespace that calls `CheckReadPath(args.Path)`. `CheckReadPath` uses `filepath.EvalSymlinks`, which requires the path to exist.
The failure appears consistent with that hook checking esbuild's disabled-module path as though it were a file to load. This is a suspected explanation, not a bisected root cause; v0.167.0 and current master have not been tested.
The original occurrence was through `instantsearch.js -> qs -> side-channel -> object-inspect@1.13.4`. That package uses `require('./util.inspect')` and maps `"./util.inspect.js"` to `false` in its `browser` field.
I searched open and closed issues and pull requests for `util.inspect`, `object-inspect`, `CheckReadPath`, and related browser-disabled/esbuild errors and did not find a matching report.
This report and the synthetic reproduction were prepared with GitHub Copilot assistance; the version comparison and control were executed locally.
Could anyone confirm whether they encounter the same behavior? Is there a recommended workaround that preserves the read-path security checks and does not require modifying third-party packages?
bep
October 23, 2026, 4:29pm
2
In general I don’t think it adds any value for anyone to double post bugs on both GitHub and here:
master ← bep:fix/issue-15481
opened 04:20PM - 23 Oct 26 UTC
Skip the read path check in the `OnLoad` hook for paths that don't exist,
e.g. m… odules disabled via `"browser": { "./util.inspect.js": false }` in
`package.json` and imported without the extension.
Fixes #15481
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
htnabe
October 24, 2026, 12:29am
3
Thank you for pointing that out !
I see that, from the maintainers’ perspective, this post doesn’t make sense. I’m sorry I didn’t take that into consideration.
As a Hugo user myself, whenever I encountered a problem I couldn’t solve, I would always start by looking for a workaround on this forum, so I assumed it would be helpful to other developers facing or someone who will face the same issue.
However, I’ll try to avoid doing that in the future.
Finally, I really like Hugo and this community. I’m not against them.