diff --git a/.changeset/brave-pants-drive.md b/.changeset/brave-pants-drive.md new file mode 100644 index 0000000000..a76badd741 --- /dev/null +++ b/.changeset/brave-pants-drive.md @@ -0,0 +1,5 @@ +--- +"@pnpm/core": patch +--- + +Don't fail on skipped optional dependencies, when searching for dependencies that should be built. diff --git a/pkg-manager/core/src/install/index.ts b/pkg-manager/core/src/install/index.ts index 1bc97b329c..808517b20f 100644 --- a/pkg-manager/core/src/install/index.ts +++ b/pkg-manager/core/src/install/index.ts @@ -1420,7 +1420,7 @@ const _installInContext: InstallFunction = async (projects, ctx, opts) => { const depsRequiringBuild: DepPath[] = [] if (opts.returnListOfDepsRequiringBuild) { await Promise.all(Object.entries(dependenciesGraph).map(async ([depPath, node]) => { - if (node == null) return // We cannot detect if a skipped optional dependency requires build + if (node?.fetching == null) return // We cannot detect if a skipped optional dependency requires build const { files } = await node.fetching() if (files.requiresBuild) { depsRequiringBuild.push(depPath as DepPath)