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

Running yarn add inside a workspace with pnp enabled installs all node_modules #6614

Open
onigoetz opened this issue Nov 1, 2018 · 6 comments
Assignees
Labels

Comments

@onigoetz
Copy link

onigoetz commented Nov 1, 2018

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
I have a project with a workspace (around 10 packages) When I run yarn add inside one of the workspaces, it installs all node_modules even though I enabled PNP on the root package

If the current behavior is a bug, please provide the steps to reproduce.

  1. Have a project with workspaces
  2. Run yarn --pnp on the root
  3. Go to one of the packages
  4. Run yarn add -D jest-pnp-resolver jest-resolve
  5. You can see that all node_modules have been reinstalled

What is the expected behavior?

Step 5 should be that it installed the package, but no node_modules should be present

Please mention your node.js, yarn and operating system version.

MacOS 10.14
Node 10.13.0
Yarn 1.12.1

@ghost ghost assigned imsnif Nov 1, 2018
@ghost ghost added the triaged label Nov 1, 2018
@ericclemmons
Copy link

It also happens via yarn workspace NAME add [...deps].

@KwanMan
Copy link

KwanMan commented Nov 7, 2018

seems the workspace package.json also needs

{
  "installConfig": {
    "pnp": true
  }
}

which i assume is a bug, i assume it's supposed to inherit from the root package.json

@onigoetz
Copy link
Author

onigoetz commented Nov 7, 2018

@KwanMan I do have this on the workspace root, it was added when I ran yarn --pnp for the first time.
Should I have it on all the sub-packages as well ?

@KwanMan
Copy link

KwanMan commented Nov 7, 2018

Yea I had to add it to any sub-package I wanted to run yarn add in. Then it installed as expected, no node_modules

@onigoetz
Copy link
Author

onigoetz commented Nov 8, 2018

Good to know there is a workaround, but I'd expect that it understand that it's in a pnp-enabled repo, like it can understand when it's in a workspace and install the dependencies in the parent.

@arendjr
Copy link

arendjr commented Oct 13, 2020

I stumbled upon this bug because I was searching whether it's possible to have a monorepo with PnP enabled in some of the workspaces, but not in others. Seems that thanks to this "bug" it is? In that case for me it's a feature, though I admit it might be a confusing one.

In any case, I thought I'd mention this, because if this gets fixed, it would be nice if there's an official way to enable PnP is some workspaces only.

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

No branches or pull requests

5 participants