suchen

Heim  >  Fragen und Antworten  >  Hauptteil

Das Modul „/node_modules/.vite/deps/vue.js“ exportiert nicht wie erforderlich einen Standard namens „default“.

Hier sind meine Fragen. Ich habe mein Projekt über Vite im Bibliotheksmodus gepackt. Immer wenn meine Bibliothek eine UI-Bibliothek eines Drittanbieters wie vue-loading-overlay enthält, tritt der Fehler auf. Aber andere Bibliotheken wie moment.js werden kein Problem haben.

Das ist meine vite.config.js. Stimmt etwas mit meiner Konfiguration nicht?

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

export default defineConfig({
  plugins: [vue()],
  build: {
    lib: {
      entry: resolve(__dirname, "src/lib.ts"),
      name: "my-ui-lib",
      fileName: "my-ui-lib",
    },
    rollupOptions: {
      external: ["vue"],
      output: [
        {
          format: "es",
          exports: "named",
          globals: { vue: "vue" },
        },
      ],
    },
  },
});
P粉006540600P粉006540600475 Tage vor732

Antworte allen(1)Ich werde antworten

  • P粉127901279

    P粉1279012792023-10-23 09:05:10

    最后我解决了我的问题,在 vite.config.js 中添加以下内容。它对我有用。

    build: {
    
       /** If you set esmExternals to true, this plugins assumes that 
         all external dependencies are ES modules */
    
       commonjsOptions: {
          esmExternals: true 
       },
    }

    Antwort
    0
  • StornierenAntwort