Today is the 10th, and my Hugo site has always looked wrong. I forgot what I did to it, and it only deployed successfully once.
So today I decided to fix it.
1 ¶
Let’s look at the error log; it shows:
sh: line 1: apt-get: command not found
Error: Command "apt-get update && apt-get install -y hugo" exited with 127
Although I’m not a professional programmer, I vaguely remember that Vercel is a serverless platform whose build environment doesn’t provide a full Linux system, so it doesn’t support commands like apt-get
.
I don’t know exactly why this happened. When I worked with Hugo, most of the setup was done by a ChatGPT agent, so I suspected it had created a vercel.json
to change the Vercel project settings.
So I went to Project Settings → Build & Development Settings and found these values (they were actually set this way):
setting | value |
---|---|
Framework Preset | Hugo |
Build Command | apt-get update && apt-get install -y hugo |
Output Directory | public |
Development Command | hugo server -D |
2 ¶
That fixed the first problem, but a second issue appeared:
Installing Hugo version 0.151.0 ← Hugo provided by Vercel
Installing dependencies...
+ hugo-bin 0.146.1 ← hugo-bin is also installed in your project's package.json
I recognized the issue: the project was installing a different Hugo version because hugo-bin
was listed in package.json
(probably added by the ChatGPT agent).
So the solution was:
-
Open the project’s
package.json
. -
Remove
hugo-bin
fromdevDependencies
, for example:"devDependencies": { "hugo-bin": "..." }
-
Delete
pnpm-lock.yaml
(or your lockfile). -
Re-run
pnpm install
(ornpm install
) locally.
Conclusion ¶
Finally, it worked. I’m exhausted.