Fix "packages field missing or empty" in Cloudflare Workers Builds
To fix "ERROR packages field missing or empty" in Cloudflare Workers Builds, pin a newer pnpm: add "packageManager": "pnpm@10.28.0" to package.json. The message comes from pnpm, not from Cloudflare. The Workers Builds image defaults to pnpm 9.10.0, and that version refuses a pnpm-workspace.yaml that holds only settings such as allowBuilds and has no packages list. I reproduced it on Windows: pnpm 9.10.0 and every version I ran up to 10.4.1 fail with exit code 1, and pnpm 10.5.0 and every later version I ran pass.
Why a Workers Builds Log Says pnpm 9.10.0
The failing log has three lines that matter. They are quoted here from a public pull request, chrisspiegl/ChrisSpiegl.com#10, which I read on 2026-11-23. I did not run a build on a Cloudflare account, so I have not seen this log myself:
Detected the following tools from environment: nodejs@24.22.3, pnpm@9.10.0
Installing project dependencies: pnpm install --frozen-lockfile
ERROR packages field missing or empty
The first line is the cause. The Cloudflare build image page (last modified 2026-10-29, read 2026-11-23) lists pnpm 9.10.0 as the default and says Workers Builds picks the pnpm version in this order:
- the
packageManagerkey in the rootpackage.json - a
devEnginesentry that names pnpm with a version - the
PNPM_VERSIONbuild variable - the image default, 9.10.0
So a project that was set up with a recent pnpm on a laptop, with no pin, gets pnpm 9.10.0 in the build. Recent pnpm releases also move settings into pnpm-workspace.yaml, which leaves a file with settings and no packages key. That file is what 9.10.0 cannot read.
Reproduce It Before You Push
You do not need a Cloudflare build to see the error. I made a throwaway project with one dependency (is-odd@3.0.1), a lockfile written by pnpm 10.34.9, and this pnpm-workspace.yaml:
allowBuilds:
esbuild: true
Then I ran the install command from the build log with the pnpm version from the log:
npx -y pnpm@9.10.0 install --frozen-lockfile
ERROR packages field missing or empty
For help, run: pnpm help install
Exit code 1, the same text as the build log. A lockfile written by pnpm 10 installs fine under 9.10.0 once the file is valid, so the lockfile is not the problem. I ran this on Windows 11 with Node 25.2.1. The Workers Builds image uses Node 24.22.1 per the docs, which I did not run.
Which pnpm Versions Fail
I ran npx -y pnpm@<version> install --frozen-lockfile in five copies of the project that differ only in the workspace file. Each cell is the exit code. A 1 carries the error above:
pnpm settings-only packages: [] packages: ["."] no file
9.10.0 1 0 0 0
9.15.9 1 0 0 0
10.0.0 1 0 0 0
10.4.1 1 (not run) (not run) (not run)
10.5.0 0 (not run) (not run) (not run)
10.15.1 0 0 0 0
10.16.0 0 0 0 0
10.28.0 0 0 0 0
10.34.9 0 0 0 0
11.9.0 0 0 0 0
11.29.0 0 0 0 0
12.23.0 0 0 0 0
"Settings-only" was allowBuilds in one copy and onlyBuiltDependencies in another, with the same result in every row. To find the boundary I bisected the allowBuilds copy: 10.2.1, 10.3.0 and 10.4.1 fail, and 10.5.0, 10.5.1, 10.5.2, 10.6.0, 10.6.5, 10.10.0, 10.12.4, 10.13.1, 10.14.0 and 10.15.0 pass. Only 10.4.0 sits between 10.4.1 and 10.5.0 in the release list, and I did not run it.
Two results differ from what I read before running. One third-party pull request says pnpm 10.16 or later is needed. On this file the line is 10.5.0, so a project pinned to 10.5 through 10.15 builds fine. And an explicit packages: [] passes on 9.10.0 in my run, so the word "empty" in the message is misleading: only a missing key fails here.
A Vercel community thread reports the same error with packageManager set to pnpm 11.9.0. I could not reproduce that: 11.9.0 passed all five cases. I can say that 11.9.0 itself is not the cause on this file. Why that build failed, I do not know.
Four Fixes, Measured
Every fix started from the failing setup: the settings-only file, pnpm 9.10.0, pnpm install --frozen-lockfile. I installed Corepack 0.36.0 from npm into a throwaway folder (Node 25 no longer ships it) so that pnpm resolved the way it does in a Corepack build.
1. Pin pnpm with packageManager (the one I recommend)
"packageManager": "pnpm@10.28.0"
With this in package.json, pnpm -v printed 10.28.0 and the install exited 0 (Done in 368ms using pnpm v10.28.0). With "packageManager": "pnpm@9.10.0" and the same file, pnpm -v printed 9.10.0 and the install failed. This key sits first in the Workers Builds order above, so it beats PNPM_VERSION and the image default. It also pins your laptop and CI to the same version. Pick the version you wrote the lockfile with.
2. Add a packages list
packages:
- "."
allowBuilds:
esbuild: true
pnpm 9.10.0 exited 0 with this file. The pnpm docs say that if packages is omitted, only the root package is included in the workspace (pnpm.io/pnpm-workspace_yaml, read 2026-11-23), so "." says the same thing explicitly. It works on every version in the table, which makes it the safest fix if you cannot move off an older pnpm. It leaves you on pnpm 9.10.0, which does not read newer settings.
3. Delete pnpm-workspace.yaml
pnpm 9.10.0 exited 0 with no file. It is the fastest fix and it throws away the settings in the file, such as allowBuilds. Use it only if the file holds nothing you need.
4. Set devEngines.packageManager (mixed result)
"devEngines": {
"packageManager": { "name": "pnpm", "version": "10.28.0", "onFail": "download" }
}
The build image docs say Workers Builds honours this key. That is quoted, not tested. Locally it failed for me. With no packageManager field, Corepack 0.36.0 downloaded pnpm 12.21.0 instead of 10.28.0, and pnpm stopped with ERR_PNPM_BAD_PM_VERSION: it was configured for 10.28.0 but Corepack had started 12.21.0. I got the same with ^10.28.0 and with no onFail. Running the pnpm 10.28.0 binary directly passed, and pnpm 9.10.0 run directly ignored the key and failed with the original error.
I do not know which Corepack version the Workers Builds image has, so this result may not carry over. If you need a guarantee, use fix 1.
PNPM_VERSION in the Dashboard
The build image page names PNPM_VERSION as a build variable that sets the pnpm version, and says project version requirements take precedence over it. I could not run this one without a Cloudflare account, so it is quoted from the docs (read 2026-11-23), not tested. It is the right tool when you cannot edit package.json. Otherwise a pinned packageManager travels with the repo, and a dashboard variable does not.
Want more like this?
New posts in your inbox, a few a month.
Which Fix to Pick
- You use a recent pnpm locally: fix 1. Pin the version that wrote your lockfile.
- You must stay on pnpm 9: fix 2. Add
packages: ["."]. - The file only has settings you do not need: fix 3.
Before you push, run npx -y pnpm@9.10.0 install --frozen-lockfile next to your lockfile. If it fails, the Workers Builds image will too.
What I Could Not Check
- A real Workers Builds run. The log lines above are quoted from a public pull request.
- The Corepack and Node versions inside the build image.
- Whether
allowBuildsblocks or allows build scripts on a given pnpm. I only measured whether the file parses. - Workspaces with several packages. My project had one root package.
The default can change. When Cloudflare moves the image past pnpm 10.5, the settings-only file stops failing on an unpinned project. Check the build image page for the current default.
Frequently Asked Questions
Is "packages field missing or empty" a Cloudflare error?
No. pnpm prints it when it reads a pnpm-workspace.yaml with no packages key. Workers Builds runs pnpm install --frozen-lockfile, so you see it in the build log.
Which pnpm versions raise "packages field missing or empty"?
In my run on Windows, 9.10.0, 9.15.9, 10.0.0, 10.2.1, 10.3.0 and 10.4.1 raised it for a settings-only file. 10.5.0 and every later version I ran, up to 12.23.0, did not.
How do I fix it without changing the pnpm version?
Add packages: ["."] to pnpm-workspace.yaml, or delete the file if it has nothing you need. Both exited 0 on pnpm 9.10.0.
Does an empty packages list also fail?
Not in my run. packages: [] exited 0 on every version I tried, including 9.10.0.
Does PNPM_VERSION fix it?
It should, if no packageManager or devEngines entry overrides it, per the Cloudflare build image docs. I did not test it.
More From XNDR
- Cloudflare Workers AI free tier: what 10,000 neurons buy, another measured Cloudflare post.
- XNDR services: edge APIs, CI and AI features on Cloudflare.
Liked this one? Get the next in your inbox.
New posts and the odd product note, a few emails a month. Easy to leave.