Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 63bfaac

Browse files
committed
fix(nuxt): handle errors resolving package paths
1 parent e1b3c5e commit 63bfaac

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/nuxt/src/core/nuxt.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { dirname, join, normalize, relative, resolve } from 'pathe'
22
import { createDebugger, createHooks } from 'hookable'
33
import type { LoadNuxtOptions } from '@nuxt/kit'
44
import { addBuildPlugin, addComponent, addPlugin, addRouteMiddleware, addVitePlugin, addWebpackPlugin, installModule, loadNuxtConfig, logger, nuxtCtx, resolveAlias, resolveFiles, resolvePath, tryResolveModule, useNitro } from '@nuxt/kit'
5+
import { resolvePath as _resolvePath } from 'mlly'
56
import type { Nuxt, NuxtHooks, NuxtOptions } from 'nuxt/schema'
67
import { resolvePackageJSON } from 'pkg-types'
78

@@ -64,9 +65,10 @@ async function initNuxt (nuxt: Nuxt) {
6465

6566
const coreTypePackages = ['nitropack', 'defu', 'h3', '@unhead/vue', 'vue', 'vue-router', '@nuxt/schema']
6667
const paths = Object.fromEntries(await Promise.all(coreTypePackages.map(async pkg => {
67-
const path = await resolvePath(pkg).then(r => resolvePackageJSON(r))
68+
const path = await _resolvePath(pkg, { url: nuxt.options.modulesDir }).then(r => resolvePackageJSON(r)).catch(() => null)
69+
if (!path) { return }
6870
return [pkg, [dirname(path)]]
69-
})))
71+
})).then((r) => r.filter(Boolean) as [string, [string]][]))
7072

7173
// Set nitro resolutions for types that might be obscured with shamefully-hoist=false
7274
nuxt.options.nitro.typescript = defu(nuxt.options.nitro.typescript, {

0 commit comments

Comments
 (0)