vuetify: [Bug Report][3.0.0-alpha.9][SSR] Cannot find module 'vuetify/lib/components'

Environment

Vuetify Version: 3.0.0-alpha.9 Vue Version: 3.0.11 Browsers: Chrome 91.0.4472.102 OS: Chromium OS 13904.55.0

Steps to reproduce

  1. yarn install
    
  2. yarn dev
    
  3. Go to https://localhost:3000

Expected Behavior

No error is thrown.

Actual Behavior

Error is thrown:

Error: Cannot find module 'vuetify/lib/components' from '/home/brillout/tmp/vuetify3-ssr/pages/_default'
    at Function.resolveSync [as sync] (/home/brillout/tmp/vuetify3-ssr/node_modules/resolve/lib/sync.js:107:15)
    at resolveFrom$3 (/home/brillout/tmp/vuetify3-ssr/node_modules/vite/dist/node/chunks/dep-11db14da.js:4076:29)
    at resolve (/home/brillout/tmp/vuetify3-ssr/node_modules/vite/dist/node/chunks/dep-11db14da.js:73358:22)
    at nodeRequire (/home/brillout/tmp/vuetify3-ssr/node_modules/vite/dist/node/chunks/dep-11db14da.js:73337:25)
    at ssrImport (/home/brillout/tmp/vuetify3-ssr/node_modules/vite/dist/node/chunks/dep-11db14da.js:73290:20)
    at eval (/pages/_default/vuetify.js:9:31)
    at instantiateModule (/home/brillout/tmp/vuetify3-ssr/node_modules/vite/dist/node/chunks/dep-11db14da.js:73323:166)

Reproduction Link

https://github.com/brillout/vuetify3-ssr

Other comments

Hi, is vuetify supposed to work with SSR and Vite?

Trying to use Vuetify + Vite + SSR leads to an error where the npm package resolve cannot find vuetify/lib/components.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 5
  • Comments: 16 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Alpha 11 now uses package exports, so you should be able to import from vuetify/components without an extension.

That was for the dev environment which imports from src. To get prod working with vite you might have to change the import to vuetify/lib/components/index.mjs. I’ll see if adding package exports makes it work without the extension.

There’s an example here although I don’t see any component import: https://github.com/vuetifyjs/vuetify/tree/next/packages/vuetify/dev

According to a conversation on Discord, I think @KaelWD got import * as components from "vuetify/lib/components" working.

same thing with vite-ssg, looks like it compiles import * as components from 'vuetify/lib/components' into require('vuetify/lib/components') which causes that error (same with directives)