pnpm: `pnpm deploy --prod` fails due to missing `devDependencies`

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

No response

Which area(s) of pnpm are affected? (leave empty if unsure)

CLI

Link to the code that reproduces this issue or a replay of the bug

https://github.com/haines/pnpm-deploy-missing-workspace-package

Reproduction steps

  1. Have a workspace package listed in devDependencies
  2. Delete the workspace package
  3. Run pnpm --filter=./packages/whatever deploy --prod dist
  4. ERR_PNPM_WORKSPACE_PKG_NOT_FOUND

Describe the Bug

We are trying to avoid compiling all our development-only workspace packages in our production Docker build, so we have added them to .dockerignore.

pnpm install --frozen-lockfile works correctly (even though the missing packages are referenced in pnpm-lock.yaml.

pnpm deploy --prod fails with ERR_PNPM_WORKSPACE_PKG_NOT_FOUND despite the fact that the missing packages are only referenced in devDependencies.

I tried adding a pnpm remove step before deploying to remove the missing dependencies from the lockfile, but that fails as well with ERR_PNPM_CANNOT_REMOVE_MISSING_DEPS.

If I use e.g. sed to remove the missing package from the devDependencies in package.json, then pnpm deploy --prod succeeds.

Expected Behavior

Missing devDependencies should not cause pnpm deploy --prod to fail, because they shouldn’t be installed anyway.

Which Node.js version are you using?

22.11.0

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

If your OS is a Linux based, which one it is? (Include the version if relevant)

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 16 (13 by maintainers)

Commits related to this issue

Most upvoted comments

Sorry, I realise now that this is a dupe of https://github.com/pnpm/pnpm/issues/7281, so I’ll close it.

pnpm deploy ignores the existing lockfile currently.

Oh ok, I did not expect that. I was using deploy in my Docker build (from the docs that seems to be one of the primary use cases) but if it doesn’t respect the lockfile then the build isn’t reproducible, which kinda defeats the purpose.

@haines I will reopen this issue to continue the discussion. If you don’t want to be annoyed by GitHub notifications, just click “unsubscribe”.

@zkochan What I meant is we would write a custom function that recursively replicates the structure of node_modules/.pnpm, except the symlinks to the workspace, those will be replicated as directories of reflinks, except the node_modules directories inside them, those will be replicated as directories of symlinks to the new node_modules/.pnpm/* at the deploy location. Is this feasible? What do you think would be the downside?