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] Root level gets local version of dependency instead of version from registry #2672

Closed
DmitriyZverev opened this issue Feb 11, 2021 · 1 comment
Labels
Bug thing that needs fixing Release 7.x work is associated with a specific npm 7 release

Comments

@DmitriyZverev
Copy link

When I use workspaces, and on the root level I need a previous version of a package (package was defined in workspaces), I get current (local) version of the package.

Steps To Reproduce:

There is a file structure:

root/
│
├── packages/
│   │
│   ├── foo/
│   │   │ 
│   │   └── package.json
│   │
│   └── bar/
│       │ 
│       └── package.json
│
└── package.json

Where:

  • root/package.json:

    {
        "name": "@scope/root",
        "wokspaces": [
            "packages/*"
        ],
        "dependencies": {
            "@scope/foo": "1.0.0-dev.0"
        }
    }
  • root/packages/foo/package.json:

    {
        "name": "@scope/foo",
        "version": "1.0.0-dev.1"
    }
  • root/packages/bar/package.json:

    {
        "name": "@scope/bar",
        "version": "1.0.0-dev.1",
        "dependencies": {
            "@scope/foo": "1.0.0-dev.0"
        }
    }

And version 1.0.0-dev.0 of package @scope/foo is already published in a private registry.

Current Behavior:

Command npm install makes next node_modules structure:

root/
│
├── node_modules/
│   │
│   └── @scope/
│       │
│       └── foo/ -> root/packages/foo (symlink to 1.0.0-dev.1)
│
└── packages/
    │
    └── bar/
        │ 
        └── node_modules/
            │
            └── @scope/
                │
                └── foo/ (installed 1.0.0-dev.0 from registry)

So when I require @scope/foo package on the root level, I get version 1.0.0-dev.1 although dependency for @scope/root was defined as 1.0.0-dev.0.

Expected Behavior:

Command npm install makes next node_modules structure:

root/
│
└── node_modules/
    │
    └── @scope/
        │
        └── foo/ (installed 1.0.0-dev.0 from registry)

So when I require @scope/foo package on the root level, I get version 1.0.0-dev.0 as expected.

Environment:

  • OS: Linux Mint 20.1
  • Node: 15.4.0
  • npm: 7.5.3
@DmitriyZverev DmitriyZverev 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 11, 2021
@darcyclarke
Copy link
Contributor

@DmitriyZverev this seems to be working as intended; You can resolve this by removing the workspace dep on foo@1.0.0-dev.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

2 participants