pnpm: `pnpm deploy` doesn't rewrite `workspace:*` dependencies in `package.json`
pnpm version:
7.30.0
Code to reproduce the issue:
Run pnpm -F <project> deploy
Expected behavior:
When the target directory is created, I expected the package.json to be “updated” to include the workspace packages with their respective version numbers similar to pnpm pack or pnpm publish.
Actual behavior:
workspace:* versions remain in package.json. This in turn means consumers of the output directory can’t rely on npm/yarn or any other package manager. A temporary workaround would be to pnpm pack the target directory, then pull the “clean” package.json from the tarball, and put that back into the target directory of the deploy.
Additional information:
node -vprints: v18.12.1- Windows, macOS, or Linux?: any
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 14
- Comments: 16 (6 by maintainers)
It might be somewhat related, in my case since
deploydoesn’t create a flatnode_modules, the docker image cannot find packages that would be in the workspace rootpackage.jsondependencies. But strangely this only happens in docker, on local deploy seems to work fine, it’s probably more nuanced.Point is all of this added complexity and headache could be entirely avoided if
pnpm deploycreated somethingnpmcompatible. That would be really nice.Thanks @pkerschbaum! We ended up working around this by relying on the output of
packand pulling the “correct” package.json from that (in a Dockerfile):+1 to this. It is a critical blocker to adopting
pnpmin any organization that has multiple projects on yarn or npm, as simply trying to install local packages usingportal:or links becomes impossible.It appears that it’s a careless mistake which still remains in version 8.0.0-rc1. Nevertheless, it is not a significant issue since the code is capable of running without the need for package.json.
This really depends on your actual use case. In my case, it’s a major blocker that requires the workaround 🤷🏻
I believe this is addressed by https://github.com/pnpm/pnpm/pull/6943
Which is not released yet, but hopefully will be soon
I’m distributing an app through a Docker image that relies on
pnpm deployto generate the final “dist” that’s shipped. To keep the image lightweight, it’s “just” node18-alpine and our dist folder, that in turn also means that the user may or may not have to interact with the packages throughnpminstead ofpnpm. Even though it’s recommended to enable pnpm with corepack in that case, that’s not always followed or feasible. When trying to use anynpmcommand against the package (likenpxto run thebin), it’ll fail as the package.json file is “invalid” in that context 👍🏻Had the same problem, and solved it with a script which replaces the
workspace:protocol of workspace dependencies by the respective version number.Maybe it helps you as a workaround.
Hmm, unfortunately #6943 has been reverted by https://github.com/pnpm/pnpm/pull/7058. Is there another solution? I’m also facing this problem in the context of docker images.
@rijkvanzanten Just curious. If you need to read the version of your dependencies at runtime, you probably want to get it like
Alternatively you can get the versions from the lock file.