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

When using pnpm i to install dependencies, it does not prioritize searching for packages with the same name in the workspace. #7973

Open
2 of 4 tasks
TransonQ opened this issue Apr 19, 2024 · 5 comments

Comments

@TransonQ
Copy link

TransonQ commented Apr 19, 2024

Verify latest release

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

pnpm version

9.0.4

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

Dependencies resolver

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

https://github.com/TransonQ/pnpm-9-monorpeo-demo

Reproduction steps

open repository minimal reproduction pnpm-9-monorpeo-demo

├───📁 apps/
│   └───📁 aaa/
│       └───📄 package.json
├───📁 packages/
│   └───📁 utils/
│       ├───📄 package.json
│       └───📄 test.ts
├───📄 package.json
├───📄 pnpm-lock.yaml
└───📄 pnpm-workspace.yaml

apps/aaa/ (pnpm v9.0.4)

pnpm i @test/utils

image

apps/aaa/ (pnpm v8.15.7)

pnpm i @test/utils
image

Describe the Bug

When I execute pnpm i @test/utils in the project, pnpm does not prioritize searching for the local workspace, but instead directly searches the npm registry, resulting in an error. Even though I manually added the workspace dependency in the project, I still encounter the same error. Is there a change in the pnpm workspace mechanism? I couldn't find any relevant explanation in the documentation.

Expected Behavior

pnpm should prioritize searching for packages within the workspace.

Which Node.js version are you using?

v18.20.1

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

@zkochan
Copy link
Member

zkochan commented Apr 21, 2024

Run pnpm add @test/utils --workspace

@stevebeauge
Copy link

Run pnpm add @test/utils --workspace

Is this a workaround or is it the expected way to add workspace dependency ? I agree with @TransonQ that local packages should be the default ones

thx

@zkochan
Copy link
Member

zkochan commented Apr 22, 2024

We can make it the default.

@stevebeauge
Copy link

We can make it the default.

So it was in v8 and earlier isn't it? You have my voice to make it the default, but I don't measure the impact or side effects and if my usage is the most common

@TransonQ
Copy link
Author

Run pnpm add @test/utils --workspace 运行 pnpm add @test/utils --workspace

Thank you for your response. This issue was discovered during my upgrade from pnpm 8 to 9, and I hope that these changes in default behavior can be marked in the release notes :)

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

No branches or pull requests

3 participants