Today is the 10th, and my Hugo site has been looked wrong. I forgot what I did to it, and it only deployed successfully once.
So today, I decided to fix it.
1 ¶
I checked the error log, and it showed:
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 remembered 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 wasn’t exactly sure 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 file that modified the Vercel project settings.
So I went to Project Settings → Build & Development Settings and found these values (they were indeed 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 then 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 realized what was happening: 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-binfromdevDependencies, 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.