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] workspace is not respected when updating package deps #4226

Closed
2 tasks done
jasonwilliams opened this issue Jan 9, 2022 · 1 comment
Closed
2 tasks done

[BUG] workspace is not respected when updating package deps #4226

jasonwilliams opened this issue Jan 9, 2022 · 1 comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release

Comments

@jasonwilliams
Copy link

jasonwilliams commented Jan 9, 2022

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

  • run npm i inside of a workspace folder, instead of updating the top-level package-lock a new one is created. This is the wrong behaviour for workspaces.

I understand that this can be "fixed" by only running said command at the top-level but it's not ideal as its too-easy of a mistake to npm i on a package instead and end up committing the new package-lock.

Yarn & pnpm's handling of this reduces potential bugs by detecting a workspace then updating the top-level package-lock.json only. It shouldn't be too much trouble to adopt that approach.

See below for an example:

 classDiagram
      Workspace <|-- Project A
      Workspace <|-- Project B
      Workspace: package.json
      Workspace: package-lock.json

      class Project A{
          package.json
      }
      class Project B{
          package.json
      }
Loading
  • $ cwd projectA
  • $ npm i
 classDiagram
      Workspace <|-- Project A
      Workspace <|-- Project B
      Workspace: package.json
      Workspace: package-lock.json

      class Project A{
          package.json
          package-lock.json
      }
      class Project B{
          package.json
      }
Loading

Undefined behavior

Expected Behavior

package-lock is updated inside the workspace folder

Steps To Reproduce

Environment

  • npm: v8.3.0
  • Node.js: v17.3.0
  • OS Name: Windows (WSL)
  • System Model Name:
  • npm config:
; node bin location = /home/jasew/.nvm/versions/node/v17.3.0/bin/node
; cwd = /home/jasew/workspace/npm-testcase/project-a
; HOME = /home/jasew
; Run `npm config ls -l` to show all defaults.

RFC: https://github.com/npm/rfcs/blob/main/implemented/0026-workspaces.md

Prior Art

pnpm - https://pnpm.io/workspaces#shared-workspace-lockfile
yarn - https://classic.yarnpkg.com/lang/en/docs/workspaces/#toc-why-would-you-want-to-do-this

@jasonwilliams jasonwilliams added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Jan 9, 2022
@nlf
Copy link
Contributor

nlf commented Feb 10, 2022

this is fixed in npm@8.5.0 with automatic workspace root detection

@nlf nlf closed this as completed Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

No branches or pull requests

3 participants
@nlf @jasonwilliams and others