electron-vue 执行npm run build无法打包 提示 Identifier 'tasks' has already been declared解决方案
electron-vue 舆情监控项目实战教程访问: https://www.itying.com/goods-929.html
使用electron-vue开发好的项目通过npm run dev可以运行,但是执行npm run build提示下面错误:
1、electron-vue npm run build提示 Identifier ‘tasks’ has already been declared
const tasks = new Listr(
^
SyntaxError: Identifier 'tasks' has already been declared
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
大概的错误就是build.js中tasks变量重复声明
解决办法:
找到 项目根目录 .electron-vue/build.js修改下面代码,修改其中一对的tasks变量名,需要注意的是本文件中一共包含四个tasks,前两个是一对,后两个是一对,修改时请对应修改
详情见下图
修改完成重新运行 npm run build 又会提示下面错误
2 、electron-vue npm run build提示 ) ReferenceError: Multispinner is not defined
(node:28120) UnhandledPromiseRejectionWarning: ReferenceError: Multispinner is not defined
at build (D:\electron\electronDemo03\.electron-vue\build.js:38:13)
at Object.<anonymous> (D:\electron\electronDemo03\.electron-vue\build.js:24:6)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
解决方法: 安装multispinner模块 在.electron-vue\build.js 引入multispinner 原因: .electron-vue\build.js文件中,代码中使用了 Multispinner ,但没有在开头引用,并且package.json文件中也没有这个依赖文件。
解决方法 先安装 Multispinner ,再在文件中引用
cnpm i multispinner --save
注意单词大小写
const Multispinner = require('multispinner')
修改完成后重新运行 npm run build
如果网络没有问题的话就可以打包了,但是如果网络有问题会提示下面错误
3 、Build:connect ETIMEDOUT 13.229.188.59:443 网络问题的解决方案 找个梯子软件–可以联系itying客服获取
? Get https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-3.0.3.2/nsis-3.0.3.2.7z: read tcp 192.168.210.64:59268->13.229.188.59:443: wsarecv: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
github.com/develar/app-builder/pkg/download.(*Downloader).follow.func1
/Volumes/data/Documents/app-builder/pkg/download/downloader.go:158
github.com/develar/app-builder/pkg/download.(*Downloader).follow
/Volumes/data/Documents/app-builder/pkg/download/artifactDownloader.go:27
原因: 外网下载build需要的依赖(winCodeSign、nsis、nsis-resources),比较慢 解决方案: 科学上网