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

auto-install-peer does not work on with workspace/link #4842

Open
rafaelliu opened this issue Jun 2, 2022 · 5 comments
Open

auto-install-peer does not work on with workspace/link #4842

rafaelliu opened this issue Jun 2, 2022 · 5 comments

Comments

@rafaelliu
Copy link

The new auto-install-peer behavior is not working with workspace nor link protocols.

Interestingly, it seems to work with tarballs

pnpm version:

p7.1.7

Code to reproduce the issue:

$ pnpm config set auto-install-peers=true
$ mkdir main dep
$ cd dep
$ pnpm init
$ pnpm add mocha --save-peer
$ cd ..
$ cd main
$ pnpm init
$ pnpm add ../dep
$ ls node_modules

Expected behavior:

mocha would be installed along with dep on main/node_modules folder

Actual behavior:

Only dep is installed.

Additional information:

$ node -v
v14.19.0
$ uname -a
Darwin a0781793cf22.ant.amazon.com 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:47:26 PDT 2022; root:xnu-8020.101.4~15/RELEASE_ARM64_T8101 arm64 arm Darwin

Installing using pnpm after npm seems to work

  1. Npm seems to hit similar issue, they've added a --install-links flag to fix that (npm v7 does not install linked packages dependencies npm/cli#2339 (comment).
$ npm --version
8.12.0
$ npm add ../dep
$ ls node_modules | grep mocha
$ npm add ../dep --install-links
$ ls node_modules | grep mocha
mocha
  1. If I pack the dependency and add it as a tarball instead of a link, it seems to work:
$ pnpm add ../dep/dep-1.0.0.tgz
Packages: +80
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Packages are hard linked from the content-addressable store to the virtual store.
  Content-addressable store is at: /Users/rafas/Library/pnpm/store/v3
  Virtual store is at:             node_modules/.pnpm

dependencies:
+ dep 1.0.0
+ mocha 10.0.0
@rafaelliu
Copy link
Author

I came across this issue previously which may or may not be related: #4820

Feel free to move/close this if the same thing. I thought I'd share my additional info

@supalarry
Copy link

supalarry commented Jun 6, 2022

I came across this issue previously which may or may not be related: #4820

Feel free to move/close this if the same thing. I thought I'd share my additional info

Have you tried upgrading pnpm to 7.1.9 ? It seems to address this or related issue.

@lake2
Copy link

lake2 commented Jun 30, 2022

same issue +1

@zkochan
Copy link
Member

zkochan commented Jul 3, 2022

It will never work with symlinked dependencies. It is not possible to do. You either inject dep or you install mocha as a dev dependency of the dep project.

@shahyar
Copy link

shahyar commented Nov 23, 2022

Came here from #5523 which shows that @zkochan's solution does not work. In fact, sometimes pnpm install will even (randomly?) break the linkage within a workspace. This is so bad that we're having to migrate our projects off pnpm.

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