From 85de623b5aefb138aac9e55581f247bf0be9e8bd Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Thu, 27 Jun 2024 16:19:59 +0200 Subject: [PATCH] fix(nuxt): don't use app version when verifying nuxt deps (#27864) --- packages/nuxt/src/core/nuxt.ts | 6 +++--- packages/nuxt/test/load-nuxt.test.ts | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/nuxt/src/core/nuxt.ts b/packages/nuxt/src/core/nuxt.ts index 9b1bfba5e4..a14b3c9da9 100644 --- a/packages/nuxt/src/core/nuxt.ts +++ b/packages/nuxt/src/core/nuxt.ts @@ -307,7 +307,7 @@ async function initNuxt (nuxt: Nuxt) { for (const _mod of nuxt.options.modules) { const mod = Array.isArray(_mod) ? _mod[0] : _mod if (typeof mod !== 'string') { continue } - const modPath = await resolvePath(resolveAlias(mod)) + const modPath = await resolvePath(resolveAlias(mod), { fallbackToOriginal: true }) specifiedModules.add(modPath) } @@ -708,9 +708,9 @@ export async function loadNuxt (opts: LoadNuxtOptions): Promise { } async function checkDependencyVersion (name: string, nuxtVersion: string): Promise { - const path = await resolvePath(name).catch(() => null) + const path = await resolvePath(name, { fallbackToOriginal: true }).catch(() => null) - if (!path) { return } + if (!path || path === name) { return } const { version } = await readPackageJSON(path) if (version && gt(nuxtVersion, version)) { diff --git a/packages/nuxt/test/load-nuxt.test.ts b/packages/nuxt/test/load-nuxt.test.ts index 7efadc7e48..dffcdf7130 100644 --- a/packages/nuxt/test/load-nuxt.test.ts +++ b/packages/nuxt/test/load-nuxt.test.ts @@ -56,8 +56,9 @@ describe('dependency mismatch', () => { cwd: repoRoot, }) + // @nuxt/kit is explicitly installed in repo root but @nuxt/schema isn't, so we only + // get warnings about @nuxt/schema expect(console.warn).toHaveBeenCalledWith(`[nuxt] Expected \`@nuxt/kit\` to be at least \`${version}\` but got \`3.0.0\`. This might lead to unexpected behavior. Check your package.json or refresh your lockfile.`) - expect(console.warn).toHaveBeenCalledWith(`[nuxt] Expected \`@nuxt/schema\` to be at least \`${version}\` but got \`3.0.0\`. This might lead to unexpected behavior. Check your package.json or refresh your lockfile.`) vi.mocked(readPackageJSON).mockRestore() await nuxt.close()