Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pnpm add fails to add workspace package with pre-release version number #5316

Closed
xenobytezero opened this issue Sep 7, 2022 · 1 comment · Fixed by #5733
Closed

pnpm add fails to add workspace package with pre-release version number #5316

xenobytezero opened this issue Sep 7, 2022 · 1 comment · Fixed by #5733
Milestone

Comments

@xenobytezero
Copy link

pnpm version: 7.11

Code to reproduce the issue:

https://github.com/xenobytezero/bug-pnpm-install-pre-workspace.git

Steps

  1. pnpm -F @pkg/target add @pkg/public-patch
  2. pnpm -F @pkg/target add @pkg/public-pre

Expected behavior:

Both packages are detected as workspace packages and added to @pkg/target package.json with workspace:* versions

Actual behavior:

The @pkg/public-patch package adds correctly, but the @pkg/public-pre package fails as it attempts to bypass workspace packages and go to the online registry

C:\Projects\github-bugs\pnpm-install-workspace>pnpm -F @pkg/target add @pkg/public-pre  
 ERR_PNPM_FETCH_404  GET https://registry.npmjs.org/@pkg%2Fpublic-pre: Not Found - 404

Additional information:

When testing, the only difference I can see is that @pkg/public-pre has a version number with a pre-release version in the package.json (2.3.4-next.4) wheas the other package has a simple Major.Minor.Patch version (2.3.4)

  • node -v prints: 16.5.0
  • Windows, macOS, or Linux?: Windows
@xenobytezero xenobytezero changed the title pnpm add fails to add workspace package with pre-release version number pnpm add fails to add workspace package with pre-release version number Sep 7, 2022
@await-ovo
Copy link
Member

await-ovo commented Dec 2, 2022

Currently pnpm try to resolve local workspace package which doest specify version range will ignore pre-release version:
https://github.com/pnpm/pnpm/blob/main/resolving/npm-resolver/src/index.ts#L293

https://github.com/npm/node-semver#functions

For me, it's hard to say if this is a bug or not, after all, installing from npm registry is also downloading the latest tag version.

I also found that it is possible to write the dependencies directly in package.json and install them:

// packages/internal/target/package.json
  "dependencies": {
    "@pkg/public-pre": "workspace:*"
  }

$ pnpm i                  
Scope: all 4 workspace projects

dependencies:
+ @pkg/public-pre 2.3.4-next.4 <- ../../public/public-pre

Done in 1.3s

It seems that the add and install behavior is a bit inconsistent, so I feel that we can try to resolve the local package when adding if the remote package does not exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants