vuetifyjs / vuetify

🐉 Vue Component Framework
https://vuetifyjs.com
MIT License
39.33k stars 6.93k forks source link

[Bug Report][3.1.3] Vite Error "Failed to resolve entry for package vuetify" when importing Sass Module #16593

Closed nikolasdas closed 1 year ago

nikolasdas commented 1 year ago

Environment

Vuetify Version: 3.1.3 Vue Version: 3.2.47 Browsers: Google Chrome OS: Windows

Steps to reproduce

Expected Behavior

The project should run normally

Actual Behavior

Error: Failed to resolve entry for package "vuetify". The package may have incorrect main/module/exports specified in its package.json.

Reproduction Link

https://stackblitz.com/edit/vitejs-vite-jdslxa?file=src/style.scss

craigrileyuk commented 1 year ago

I'm getting this one as well, also from trying to import a config SCSS file before createVuetify:

// vuetify-config.scss
@use 'vuetify' with (
  $color-pack: false,
  $utilities: false,
  $reset: false,
);

which is imported from:

import "./vuetify-config.scss";
import { aliases, mdi } from "vuetify/iconsets/mdi-svg";
import { createVuetify } from "vuetify";

export default createVuetify({
    icons: {
        defaultSet: "mdi",
        aliases,
        sets: {
            mdi,
        },
    },
});

and results in:

throw new Error(`Failed to resolve entry for package "${id}". ` +
          ^

Error: Failed to resolve entry for package "vuetify". The package may have incorrect main/module/exports specified in its package.json.

Have confirmed that the import of the SCSS file is the only thing that causes the error

EDIT: Seems to be a problem introduced with Vite 4.1.0+, I've bumped back to v4.0.4 and it works fine.

KaelWD commented 1 year ago

Caused by https://github.com/vitejs/vite/pull/11595, vite now has no way to resolve a different sass entry without https://github.com/vitejs/vite/pull/7817

KaelWD commented 1 year ago

I opened https://github.com/vitejs/vite/issues/11947

craigrileyuk commented 1 year ago

Yep, further to your comment in the Vite repo @KaelWD , using:

@use 'vuetify/lib/styles/main.sass' with (
  $color-pack: false,
  $utilities: false,
  $reset: false,
);

Seems to be the way to go.

kstraszewski commented 1 year ago

I see that te issue is closed from last week, but I still can't use vuetify on Nuxt 3.2 or 3.3.1. Is there any way or we need to wait for vite 4.2?

@edit: getting same error on 3.1.10

Maxim-Mazurok commented 1 year ago

To be clear, this fixed it for me: replace in my main.scss: @use "vuetify" with ( with @use "vuetify/lib/styles/main.sass" with ( as per comments above

KaelWD commented 1 year ago

You can use vite 4.0 or 4.2-beta, this only exists with vite 4.1