diff --git a/packages/components/src/module.ts b/packages/components/src/module.ts index 7d1caa09f2..eaea792bef 100644 --- a/packages/components/src/module.ts +++ b/packages/components/src/module.ts @@ -5,7 +5,8 @@ import { scanComponents } from './scan' import type { ComponentsDir } from './types' const isPureObjectOrString = (val: any) => (!Array.isArray(val) && typeof val === 'object') || typeof val === 'string' -const getDir = (p: string) => fs.statSync(p).isDirectory() ? p : dirname(p) +const isDirectory = (p: string) => { try { return fs.statSync(p).isDirectory() } catch (_e) { return false } } +const getDir = (p: string) => isDirectory(p) ? p : dirname(p) export default defineNuxtModule({ name: 'components', diff --git a/playground/pages/index.vue b/playground/pages/index.vue index 97a850725a..f59a5330dc 100644 --- a/playground/pages/index.vue +++ b/playground/pages/index.vue @@ -1,6 +1,6 @@