From 379cdcaf82552f893e9671337f9aaf1f72bb1256 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Fri, 10 Jul 2020 01:16:05 +0300 Subject: [PATCH] fix: better workspace range resolution error --- .changeset/few-tips-press.md | 5 +++++ packages/npm-resolver/src/index.ts | 2 +- packages/npm-resolver/test/index.ts | 5 +++-- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 .changeset/few-tips-press.md diff --git a/.changeset/few-tips-press.md b/.changeset/few-tips-press.md new file mode 100644 index 0000000000..7bf7cb9ca5 --- /dev/null +++ b/.changeset/few-tips-press.md @@ -0,0 +1,5 @@ +--- +"@pnpm/npm-resolver": patch +--- + +When resolution from workspace fails, print the path to the project that has the unsatisfied dependency. diff --git a/packages/npm-resolver/src/index.ts b/packages/npm-resolver/src/index.ts index 2195692e0a..28f0503a55 100644 --- a/packages/npm-resolver/src/index.ts +++ b/packages/npm-resolver/src/index.ts @@ -208,7 +208,7 @@ function tryResolveFromWorkspace ( if (!resolvedFromLocal) { throw new PnpmError( 'NO_MATCHING_VERSION_INSIDE_WORKSPACE', - `No matching version found for ${wantedDependency.alias}@${pref} inside the workspace` + `In ${path.relative(process.cwd(), opts.projectDir)}: No matching version found for ${wantedDependency.alias}@${pref} inside the workspace` ) } return resolvedFromLocal diff --git a/packages/npm-resolver/test/index.ts b/packages/npm-resolver/test/index.ts index a0bc96e970..1bfbea6337 100644 --- a/packages/npm-resolver/test/index.ts +++ b/packages/npm-resolver/test/index.ts @@ -1495,10 +1495,11 @@ test('workspace protocol: resolution fails if there is no matching local package storeDir, }) + const projectDir = '/home/istvan/src' let err!: Error try { await resolve({ alias: 'is-positive', pref: 'workspace:^3.0.0' }, { - projectDir: '/home/istvan/src', + projectDir, registry, workspacePackages: {}, }) @@ -1508,7 +1509,7 @@ test('workspace protocol: resolution fails if there is no matching local package t.ok(err) t.equal(err['code'], 'ERR_PNPM_NO_MATCHING_VERSION_INSIDE_WORKSPACE') - t.equal(err.message, 'No matching version found for is-positive@^3.0.0 inside the workspace') + t.equal(err.message, `In ${path.relative(process.cwd(), projectDir)}: No matching version found for is-positive@^3.0.0 inside the workspace`) t.end() })