fix: resolve vuetify & optional deps without relying on cwd#366
Merged
Conversation
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
This was referenced Jun 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Module setup resolved Vuetify via
@vuetify/loader-shared'sresolveVuetifyBase(), which hardcodes:This throws
Cannot find module 'vuetify/package.json'whenevervuetifyisn't reachable from the project cwd — i.e. pnpm isolated installs (wherevuetifyis only the module's own dependency, not a direct app dep) and Nuxt layers (especially external/remote layers with their ownnode_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 andsass-embeddedunder the same layouts. The version probe (getPackageInfo('vuetify')) also degraded to'0.0.0'.Fix
vuetify/package.jsonvia Nuxt'sfindPath(honoursrootDir+modulesDir, incl. layers), falling back to the module's own dependency throughimport.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-stylesand nuxt/content#3791.rootDir+modulesDir) toisPackageExistsfor date adapters / icon packs /sass-embedded.resolveVuetifyBaseandisObjectimports from@vuetify/loader-shared(still used forgenerateImports).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):node_modules(vuetify only in the layer) (Nuxt Layers Cannot find module 'vuetify/package.json' #277)nuxi prepareexit 1In every "before" case the exact buggy call
require.resolve('vuetify/package.json', { paths: [process.cwd()] })reproducesMODULE_NOT_FOUND.Closes #277, #306