vite打包出現(xiàn)"default"?is?not?exported?by?"node_modules/...問題解決
項目場景:
vue3+ts+vite項目打包
問題描述
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語法,需要使用@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(),
],
}總結
到此這篇關于vite打包出現(xiàn)"default" is not exported by "node_modules/...問題解決的文章就介紹到這了,更多相關vite打包問題解決內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
vue使用threeJs導入obj模型并實現(xiàn)添加標注
這篇文章主要介紹了vue使用threeJs導入obj模型并實現(xiàn)添加標注方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-05-05
Vue將將后端返回的list數(shù)據(jù)轉(zhuǎn)化為樹結構的實現(xiàn)
本文主要介紹了Vue將將后端返回的list數(shù)據(jù)轉(zhuǎn)化為樹結構的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2022-05-05
Vue.js?前端項目在常見?Web?服務器上的部署配置過程
Web服務器支持多種編程語言,如 PHP,JavaScript,Ruby,Python 等,并且支持動態(tài)生成 Web 頁面,這篇文章主要介紹了Vue.js?前端項目在常見?Web?服務器上的部署配置,需要的朋友可以參考下2023-02-02

