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
- Have a workspace package listed in
devDependencies - Delete the workspace package
- Run
pnpm --filter=./packages/whatever deploy --prod dist 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
- feat(deploy): create dedicated lockfile Closes https://github.com/pnpm/pnpm/issues/8778 — committed to pnpm/pnpm by KSXGitHub 2 years ago
- test: https://github.com/pnpm/pnpm/issues/8778 — committed to pnpm/pnpm by KSXGitHub 2 years ago
- feat(deploy): create dedicated lockfile (#8828) * feat(deploy): create dedicated lockfile Closes https://github.com/pnpm/pnpm/issues/8778 * chore: remove a leftover `console.log` * fix: hois... — committed to FairyWorld/devtool_pnpm by KSXGitHub 2 years ago
Sorry, I realise now that this is a dupe of https://github.com/pnpm/pnpm/issues/7281, so I’ll close it.
Oh ok, I did not expect that. I was using
deployin 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 thenode_modulesdirectories inside them, those will be replicated as directories of symlinks to the newnode_modules/.pnpm/*at the deploy location. Is this feasible? What do you think would be the downside?