[BUG] npm ci
does not remove/recreate existing node_modules
inside workspaces
#7226
Closed
2 tasks done
Labels
Bug
thing that needs fixing
Good First Issue
good issue or PR for newcomers
Priority 2
secondary priority issue
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
Running
npm ci
behaves unintuitively in workspaces. When run in a project without workspaces, the behavior is straightforwards and clear:package-lock.json
is in sync./node_modules
if it existspackage-lock.json
This makes perfect sense, and aligns with the documentation. However, when you run
npm ci
in a project with workspaces, it runs the same three steps. This sounds like it's fine, except that there is one key problem with step 2: it only deletes the rootnode_modules
folder. Anynode_modules
in workspaces folders are left behind. This leads to a confusing inconsistency in the behavior of thenpm ci
command: on first install (if there are nonode_modules
installed at all), it will install the full tree, including workspaces. However, when running it a second time, it only cleanly reinstalls the root packages.Expected Behavior
I would expect that
npm ci
would remove all thenode_modules
folders referenced inpackage-lock.json
before trying to install again.Steps To Reproduce
Here is a set of commands that illustrate the issue. If you run this script you will see that the hoisted
abbrev
installation gets properly reinstalled (removingfoo.txt
), but the inner one does not.Environment
The text was updated successfully, but these errors were encountered: