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

peerDependency for a link:* dependency does not get resolved #5523

Open
Kirshach opened this issue Oct 19, 2022 · 5 comments
Open

peerDependency for a link:* dependency does not get resolved #5523

Kirshach opened this issue Oct 19, 2022 · 5 comments

Comments

@Kirshach
Copy link

While developing project B with a locally built dependency A that has a peerDependency: some-external-module , I discovered that linking module A to B and installing some-external-module in A does not result in successful resolution of some-external-module dependency in pnpm.

pnpm version:

7.13.1

Code to reproduce the issue:

  1. Create local module A with a peerDependency: some-external-module
  2. Create local module B with dependency A
  3. In module B install dependency A using its relative path, i.e. pnpm add ../module-A
  4. In module B install dependency some-external-module
  5. Run project B

Expected behavior:

The project starts up succesfully

Actual behavior:

An error is thrown:
Module not found: Error: Can't resolve 'some-external-module'

Additional information:

MacOS Monterey 12.4
node v18.8.0

@Shinyaigeek
Copy link
Member

I tried to reproduce in this repository this but I could not...

  • sub package has is-even external package as peerDependencies
  • main package has sub internal package as dependencies, and is-even external package as dependencies
  • run node main/main.js and correctly worked

Could you share the reproduction? (or please point it out if something wrong)

@Kirshach
Copy link
Author

Hm, the only difference is I was doing pnpm add ../sub, so, using a symlink. Is this a wrong way of doing it? 🤔

@shahyar
Copy link

shahyar commented Nov 14, 2022

I tried to reproduce in this repository this but I could not...

You were unable to reproduce because you're using a pnpm workspace. This means the libs are all installed in /node_modules/.

This is indeed bugged without a workspace. You'd think it would make a symlink as /main/node_modules/sub -> ../../sub/ so that when the code from /sub/ runs, it is able to find peer deps inside of /main/node_modules/ (because CWD is /main/). Unfortunately, as is, /sub tries to find peer deps from /sub/node_modules/, which would be empty in this case.

@rafaelliu
Copy link

rafaelliu commented Nov 23, 2022

I believe thats the same issue as #4842. Got a bit cryptic response there and don’t understand the underlying blocker.

NPM does it with a flag and I’m pretty sure the latest version even enables the flag by default (see linked issue).

Would be nice to have. Huge pain on monorepos

@RealAlphabet
Copy link

RealAlphabet commented Mar 14, 2023

I have the exact same problem for a very simple project.

PS: I don't know if it's related but NPM has changed from link: to file:.

If I change link: to file: in the package.json after doing pnpm add ../mymodule then it works!
I think PNPM should really use file: by default.

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

5 participants