electron常见问题汇总
开发项⽬中⽤到了electron,把平时遇到的问题整理⼀下,希望能够对⼤家有所帮助
问题⼀:搭建项⽬运⾏起来没问题,打包的时候报错
Unresolved node modules: vue
解决⽅法:
把node_modules 掉,使⽤npm install安装所有的模块,千万不要使⽤淘宝镜像安装
或者使⽤ yarn安装模块,就可以避免这个错误
问题⼆;
解决⽅法:
...Object.keys(dependencies || {}).filter(d => !whiteListedModules.includes(d))
问题三: cannot find mould bytebuffer
electron vue教程
解决⽅法:
放在dependencies依赖,不应放在devDependencies依赖,这个与个⼈开发项⽬需求有关
问题四:没有管理员权限
管理员权限运⾏开发⼯具即可,开发⼯具图标右键——属性,在⽤管理员⾝份运⾏的打勾✔即可
问题五:url协议⽹址⼀直唤醒不了本地程序exe
解决⽅案:
1、先⽤reg的⽅法直接写个注册表运⾏,⽹址可以这个注册表名唤醒,即本地的exe没问题,
<a href="Webshell://uid=001>注册表⽅式唤醒</a>
2、问题则为Inno Setup写注册表指向或者名称有问题
Root: HKCR; SubKey: Cboyi; ValueData: "URL:Cboyi Protocol Handler"; ValueType: string; Flags: CreateValueIfDoesntExist UninsDeleteKey;
Root: HKCR; SubKey: Cboyi; ValueName: "URL Protocol"; Flags: CreateValueIfDoesntExist; ValueType: string;
Root: HKCR; SubKey: Cboyi\DefaultIcon; ValueData: C:\Program Files (x86)\; Flags: CreateValueIfDoesntExist; ValueType: string;
Root: HKCR; SubKey: Cboyi\shell\open\command; ValueData:"C:\Program Files (x86)\ ""%1"""; Flags: CreateValueIfDoesntExist; ValueType: string;
问题六:yarn run build 报错
The callback-based version of packager() is deprecated and will be removed in a future major version, please convert to the Promise version or use the nodeify module.
因为安装⽐较慢,可以等⼀会或者在⽹络好的情况下打包
问题七:npm resource busy or locked..
报错: npm resource busy
解决:
⽅法⼀: 关掉360
⽅法⼆:如果还是不可以关闭开发⼯具,直接cmd打开命令⾏⼯具执⾏ yarn run build
问题⼋:Error: spawn
Error: spawn E:\meeting\h5-consultation-electron-meeting\node_modules\electron\ ENOENT
at Process.ChildProcess._it (internal/child_process.js:232:19)
at onErrorNT (internal/child_process.js:407:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
Emitted 'error' event at:
at Process.ChildProcess._it (internal/child_process.js:238:12)
at onErrorNT (internal/child_process.js:407:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! h5-electron-meeting@0.0.1 dev: `node .electron-vue/dev-runner.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the h5-electron-meeting@0.0.1 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\boyi08\AppData\Roaming\npm-cache\_logs\2019-04-04T01_57_15_066Z-debug.log
解决:因为项⽬中安装的electron模块不对
electron判定很迷,就算你设定了,他也会根据你的系统⾃⾏判断。
你看下项⽬⽬录下../node_modules/electron/dist下⾯的libEGL.dll,如果是88kb就是32位,100kb+就是64位,
下⾯⽹址下载你需要的版本即可:
问题九;vue-cli搭配electron-vue⽣成的项⽬,dev模式下运⾏⽆误.打包时出现了问题
解决⽅案:
使⽤yarn替代npm安装依赖
问题⼗;
安装cnpm:
npm install -g cnpm --registry=registry.
安装完成后报错:⽆法加载⽂件 C:\Users\yizon\AppData\Roaming\npm\cnpm.ps1,因为在此系统上
禁⽌运⾏脚本解决:管理员⾝份运⾏程序,输⼊:
set-ExecutionPolicy RemoteSigned
问题⼗⼀:Webpack ReferenceError: process is not defined
解决⽅案:
修改 .fig.js 和 fig.js如下:
fig.js⽂件
new HtmlWebpackPlugin({
filename: 'index.html',
template: solve(__dirname, '../src/index.ejs'),
templateParameters(compilation, assets, options) {
return {
compilation: compilation,
webpack: Stats().toJson(),
webpackConfig: compilation.options,
htmlWebpackPlugin: {
files: assets,
options: options
},
process,
};
},
minify: {
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true
},
nodeModules: false
}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: solve(__dirname, '../src/index.ejs'),
minify: {
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true
},
templateParameters(compilation, assets, options) {
return {
compilation: compilation,
webpack: Stats().toJson(),
webpackConfig: compilation.options,
htmlWebpackPlugin: {
files: assets,
options: options
},
process,
};
},
nodeModules: v.NODE_ENV !== 'production'        solve(__dirname, '../node_modules')
: false
}),

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。