fix(nuxt): don't use app version when verifying nuxt deps (#27864)

This commit is contained in:
Daniel Roe 2024-06-27 16:19:59 +02:00 committed by GitHub
parent 9c0f8503da
commit ac9a95cc1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View File

@ -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<Nuxt> {
}
async function checkDependencyVersion (name: string, nuxtVersion: string): Promise<void> {
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)) {

View File

@ -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()