pnpm deploy Produces an Incomplete Bundle - Fix Missing Files in CI
pnpm deploy copies a workspace package and its production dependencies into a standalone directory for shipping. If the package was not built first, or its files/exports exclude needed paths, the deployed directory is missing artifacts and fails at runtime.
What this error means
After pnpm deploy <dir>, the deployed package crashes because dist/ or other build output is absent, or a needed file is not present. The deploy succeeded, but it copied what the package declares to ship - which did not include the un-built or excluded files.
$ pnpm --filter @acme/api deploy ./out
$ node ./out/dist/index.js
Error: Cannot find module './out/dist/index.js'
# dist/ was never built before deploy, or excluded by "files"Common causes
The package was not built before deploy
pnpm deploy copies current contents; it does not build for you. Without a prior build step, dist/ is missing from the deployed directory.
files/exports exclude needed paths
A files allowlist or an exports map that does not include a required path means deploy omits it, even though it exists in the repo.
How to fix it
Build before deploying
Run the package build, then deploy so the output is present to copy.
pnpm --filter @acme/api build
pnpm --filter @acme/api deploy ./out
node ./out/dist/index.jsCheck what the package ships
- Confirm
files/exportsinclude the build output and any runtime assets. - Verify the deploy directory contents (
ls out/) before running it. - Ensure production dependencies are resolvable in the deployed tree.
How to prevent it
- Always build a package before pnpm deploy.
- Include build output and assets in files/exports.
- Verify the deployed directory before shipping.