Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.3k views
in Technique[技术] by (71.8m points)

electron-vue-vite 打包后无法运行?

源码

经初步排查,是使用了vue-router导致的,报错信息为:
Uncaught ReferenceError: exports is not defined
编译后的代码中包含Object.defineProperty(exports,"__esModule",{value:!0})谷歌了一下,说是不兼容require和import导致的,有看没懂……
但找到一个解决办法,就是在页面里追加一段代码:
<script> var exports = {}; </script>
但问题又来了:
Cannot find module './Index.b211c312.js'
报错的意思很简单,但就是不知道怎么解决,生成的文件是这样的:

│  index.html
└─_assets
        Index.b211c312.js
        index.fa062449.js
        style.032a3e7d.css

在index.html中:

<script type="module" src="./_assets/index.fa062449.js"></script>

在index.fa062449.js中:

require("./Index.b211c312.js")

同级目录下就是找不到……

源码中只包含了必要的代码,请大家帮忙看看怎么解决


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...