欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vite打包出現(xiàn)"default"?is?not?exported?by?"node_modules/...問(wèn)題解決

 更新時(shí)間:2023年11月28日 10:05:09   作者:AB12543  
這篇文章主要給大家介紹了關(guān)于vite打包出現(xiàn)"default"?is?not?exported?by?"node_modules/...問(wèn)題解決的相關(guān)資料,文中通過(guò)代碼介紹的非常詳細(xì),需要的朋友可以參考下

項(xiàng)目場(chǎng)景:

vue3+ts+vite項(xiàng)目打包

問(wèn)題描述

error during build:
RollupError: "default" is not exported by "node_modules/vue/dist/vue.runtime.esm-bundler.js", imported by "node_modules/@kangc/v-md-editor/lib/codemirror-editor.js".
    at error (file:///D:...

原因分析:

vite不支持commonjs語(yǔ)法,需要使用@rollup/plugin-commonjs插件,用于將CommonJS模塊轉(zhuǎn)換為ES6模塊的Rollup插件。

解決方案:

1.安裝@rollup/plugin-commonjs插件

npm i @rollup/plugin-commonjs

2.在vite.config.ts配置中添加該插件,注意commonjs()必須在上面,否則可能不生效,我排查了老半天

import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import commonjs from '@rollup/plugin-commonjs';//引入commojs

export default defineConfig({
  plugins: [
    commonjs() as any,
    vue(),
  ],
 }

總結(jié) 

到此這篇關(guān)于vite打包出現(xiàn)"default" is not exported by "node_modules/...問(wèn)題解決的文章就介紹到這了,更多相關(guān)vite打包問(wèn)題解決內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論