Skip to content

fix: resolve vuetify & optional deps without relying on cwd#366

Merged
AndreyYolkin merged 1 commit into
mainfrom
fix/277-resolve-vuetify-base
Jun 8, 2026
Merged

fix: resolve vuetify & optional deps without relying on cwd#366
AndreyYolkin merged 1 commit into
mainfrom
fix/277-resolve-vuetify-base

Conversation

@AndreyYolkin

Copy link
Copy Markdown
Contributor

Problem

Module setup resolved Vuetify via @vuetify/loader-shared's resolveVuetifyBase(), which hardcodes:

require.resolve('vuetify/package.json', { paths: [process.cwd()] })

This throws Cannot find module 'vuetify/package.json' whenever vuetify isn't reachable from the project cwd — i.e. pnpm isolated installs (where vuetify is only the module's own dependency, not a direct app dep) and Nuxt layers (especially external/remote layers with their own node_modules).

On Nuxt 3.16 this was a hard crash (#306). On current Nuxt it's worse: the module setup error is swallowed, so Vuetify silently fails to set up (no components/styles) with no error in the log.

The same process.cwd()-based detection (isPackageExists) silently disabled date adapters, icon packs and sass-embedded under the same layouts. The version probe (getPackageInfo('vuetify')) also degraded to '0.0.0'.

Fix

  • Resolve vuetify/package.json via Nuxt's findPath (honours rootDir + modulesDir, incl. layers), falling back to the module's own dependency through import.meta.resolve — Vuetify lives next to the module in the (pnpm) virtual store and is reachable even from external layers. Mirrors the approach in @vuetify/unplugin-styles and nuxt/content#3791.
  • Pass the project resolution paths (rootDir + modulesDir) to isPackageExists for date adapters / icon packs / sass-embedded.
  • Drop the now-unused resolveVuetifyBase and isObject imports from @vuetify/loader-shared (still used for generateImports).
  • A clear error is thrown if Vuetify genuinely can't be resolved.

Verification

  • ✅ Existing suite: 27/27 (incl. layers, sass, unplugin-styles, vuetify-config).

  • ✅ Real pnpm install matrix (module packed to a tarball, installed with different node-linker), before (main) vs after (fix):

    layout before after
    isolated, vuetify not a direct app dep (Can't install with nuxi on deno & NodeJS (pnpm) #306) 🔴 setup fails 🟢
    hoisted 🔴 (when vuetify not direct dep) 🟢
    local layers 🔴 🟢
    external layer with its own node_modules (vuetify only in the layer) (Nuxt Layers Cannot find module 'vuetify/package.json' #277) 🔴 nuxi prepare exit 1 🟢
    isolated + date adapter + icon pack 🟢 (detected)

    In every "before" case the exact buggy call require.resolve('vuetify/package.json', { paths: [process.cwd()] }) reproduces MODULE_NOT_FOUND.

Closes #277, #306

Resolve vuetify's package.json via Nuxt's `findPath`, falling back to the
module's own dependency via `import.meta.resolve`, instead of
@vuetify/loader-shared's `resolveVuetifyBase()` which hardcodes
`require.resolve(..., { paths: [process.cwd()] })`. The old behaviour failed
whenever vuetify was not reachable from the project cwd — pnpm isolated
installs (where vuetify is only the module's dependency) and Nuxt layers,
including external layers with their own node_modules.

Also pass the project resolution paths (rootDir + modulesDir) to
`isPackageExists` for date adapters, icon packs and sass-embedded, so those
optional integrations are detected under the same layouts instead of silently
disabled. As a side effect the detected vuetify version no longer falls back
to '0.0.0'. Drops the unused `resolveVuetifyBase`/`isObject` imports from
@vuetify/loader-shared.

Closes #277, #306
@AndreyYolkin AndreyYolkin added bug Something isn't working area: build Build, Vite, deps, install labels Jun 6, 2026
@AndreyYolkin AndreyYolkin changed the title fix: resolve vuetify & optional deps without relying on cwd (#277, #306) fix: resolve vuetify & optional deps without relying on cwd Jun 6, 2026
@AndreyYolkin AndreyYolkin added this to the 1.0.0 milestone Jun 7, 2026
@AndreyYolkin AndreyYolkin merged commit c7e10fa into main Jun 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: build Build, Vite, deps, install bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nuxt Layers Cannot find module 'vuetify/package.json'

1 participant