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

[BUG] not installing peer dependencies for workspaces if they are not nested inside the root package #2650

Open
talsi opened this issue Feb 8, 2021 · 2 comments
Labels
Documentation documentation related issue Enhancement new feature or improvement Release 7.x work is associated with a specific npm 7 release

Comments

@talsi
Copy link

talsi commented Feb 8, 2021

Current Behavior:

having 'library-project' with peer-dependencies adjacent to 'main-project'
and 'main-project' with workspaces: ['../library-project'] (outside of 'main-project' folder)
'npm install' in 'main-project' is not installing the peer-dependencies

example:

library-project/
  package.json      // peerDependencies: {"dep-a": "1.0.0"}
main-project/
  package.json      // "workspaces": [ "../library-project" ]

Expected Behavior:

expecting node_modules in 'main-project' after 'npm i' to include 'dep-a':

node_modules
  library-project (linked)
  dep-a

actual result: missing 'dep-a' in node_modules

this works fine if 'library-project' would be inside 'main-project'

Steps To Reproduce:

  1. main-project and library-project are two adjacent projects

  2. main-project package.json:

{
  "name": "main-project",
  "version": "1.0.0",
  "workspaces": [
    "../library-project"
  ],
  "dependencies": {
    "library-project": "1.0.0"
  }
}
  1. library-project package.json:
{
  "name": "library-project",
  "version": "1.0.0",
  "peerDependencies": {
    "@angular/core": "11.1.2"
  }
}
  1. run 'npm install' in 'main-project'

  2. expected "@angular/core" to be installed as it's a peer dependency of 'library-project'

Environment:

  • Node: 15.6.0
  • npm: 7.5.2
@talsi talsi added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Feb 8, 2021
@talsi talsi changed the title [BUG] not installing peer dependencies for workspaces that are not nested inside the root package [BUG] not installing peer dependencies for workspaces if they are not nested inside the root package Feb 8, 2021
@darcyclarke
Copy link
Contributor

darcyclarke commented Mar 12, 2021

@talsi sorry about the confusion, we should probably be throwing in these cases since our intent is not to allow workspace definitions outside of the root. Our docs should be more clear about this &/or we may allow for this in the future - although that would be a net-new feature/support.

@darcyclarke darcyclarke added Enhancement new feature or improvement pr: needs documentation pull request requires docs before merging and removed Needs Triage needs review for next steps Bug thing that needs fixing Enhancement new feature or improvement labels Mar 12, 2021
@talsi
Copy link
Author

talsi commented Mar 15, 2021

@darcyclarke

i think having built-in support for this will be much appreciated.
it's a very productive feature and it's unfortunate that it can't be used for legacy projects (it's not easy, to say the least, moving existing projects around into other projects).

fyi,
as a workaround, if anyone else is interested, you could -

  1. symlink 'library-project' into the root folder ('main-project') manually / using a tool like symlink-dir.
  2. set "workspaces": ["library-project"] (you can even use globs)

now it works as expected for me.

@lukekarrys lukekarrys added Documentation documentation related issue and removed pr: needs documentation pull request requires docs before merging labels Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation documentation related issue Enhancement new feature or improvement Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

3 participants