From d37ff6056766eb57b302904853f9844d372ae423 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Thu, 27 Oct 2022 01:10:13 +0300 Subject: [PATCH] fix: don't crash on lockfile with no packages field close #5553 --- .changeset/small-ads-warn.md | 6 ++++++ packages/resolve-dependencies/src/index.ts | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/small-ads-warn.md diff --git a/.changeset/small-ads-warn.md b/.changeset/small-ads-warn.md new file mode 100644 index 00000000000..62c11accdfe --- /dev/null +++ b/.changeset/small-ads-warn.md @@ -0,0 +1,6 @@ +--- +"@pnpm/resolve-dependencies": patch +"pnpm": patch +--- + +Don't crash on lockfile with no packages field [#5553](https://github.com/pnpm/pnpm/issues/5553). diff --git a/packages/resolve-dependencies/src/index.ts b/packages/resolve-dependencies/src/index.ts index 8b8df82f321..6e23b604168 100644 --- a/packages/resolve-dependencies/src/index.ts +++ b/packages/resolve-dependencies/src/index.ts @@ -332,8 +332,8 @@ async function finishLockfileUpdates ( // TODO: try to cover with unit test the case when entry is no longer available in lockfile // It is an edge that probably happens if the entry is removed during lockfile prune - if (requiresBuild && newLockfile.packages![depPath]) { - newLockfile.packages![depPath].requiresBuild = true + if (requiresBuild && newLockfile.packages?.[depPath]) { + newLockfile.packages[depPath].requiresBuild = true } })) }