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

[rush] rush add "package" when using npm doesn't actually add the package #2961

Open
nzjony opened this issue Oct 12, 2021 · 2 comments
Open

Comments

@nzjony
Copy link

nzjony commented Oct 12, 2021

Summary

Adding a local dependency requires deleting the npm-shrinkwrap.json file and re-running rush update. Probably a duplicate of #2928, except the problem is with npm and not yarn, but I thought perhaps best to have a separate issue for npm?

Repro steps

I have created a repository here: https://github.com/nzjony/rush-add-package-dependency-issue

Simply:

To reproduce the bug

  • git clone the repo
  • make sure you have rush installed globally, or use npx
  • rush update
  • cd packages/trunk-package
  • rush add -p leaf-package
  • rush build <- Will fail, because the index.ts tries to access an exported function from leaf-package which wasn't correctly added.

Work around:

  • rm common/config/rush/npm-shrinkwrap.json
  • rush update && rush build

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@microsoft/rush globally installed version? 5.54.0
rushVersion from rush.json? 5.54.0
useWorkspaces from rush.json? false
Operating system? Mac
Would you consider contributing a PR? No
Node.js version (node -v)? 14.18.0
@elliot-nelson
Copy link
Collaborator

Related to tickets #886 and #1013 documenting issues with Rush + NPM.

@elliot-nelson
Copy link
Collaborator

This is definitely an issue with rush update, as described by @octogonz in #886.

He describes a workaround for NPM6 as "deleting the node_modules folder and lockfile". My attempt at that approach in this branch still has some issues:

  • rush add -p XYZ works as expected
  • ✅ Add a dependency manually to package.json and run rush update works as expected
  • ✅ Edit a dependency version manually and run rush update works as expected
  • ❌ Remove a dependency manually from package.json and run rush update does not work (the symlink is still left in the node_modules folder in your project). Need to rush update --full to fully remove.
  • ❌ Cannot rush add -p LOCAL_PROJECT (in this case, rush add -p leaf-package), or manually add it and run rush update -- still need to run rush update --full to get the symlink to show up in node_modules.

Ideally, we could come up with some tricks that wouldn't require a fullUpgrade on every package edit with NPM, but so far I haven't had any luck with half-measures.

@iclanton iclanton moved this to Needs Investigation in Bug Triage Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs Investigation
Development

No branches or pull requests

2 participants