diff --git a/packages/nx/src/plugins/js/lock-file/yarn-parser.ts b/packages/nx/src/plugins/js/lock-file/yarn-parser.ts index dca2e78a2cc51..271d5246a4506 100644 --- a/packages/nx/src/plugins/js/lock-file/yarn-parser.ts +++ b/packages/nx/src/plugins/js/lock-file/yarn-parser.ts @@ -362,7 +362,10 @@ function mapSnapshots( .slice(0, key.indexOf('#')) .replace(`@patch:${packageName}@`, '@npm:'); } - if (!existingKeys.get(packageName).has(normalizedKey)) { + if ( + !existingKeys.get(packageName) || + !existingKeys.get(packageName).has(normalizedKey) + ) { keysSet.delete(key); } }