开发项目中用到了electron,把平时遇到的问题整理一下,希望能够对大家有所帮助
问题一:electron-builder搭建项目运行起来没问题,打包的时候报错
Unresolved node modules: vue
解决方法:
把node_modules 文件夹删除掉,使用npm install安装所有的模块,千万不要使用淘宝镜像安装!!!
或者使用 yarn安装模块,就可以避免这个错误
解决方法:
webpack.renderer.config.js文件中注释掉
...Object.keys(dependencies || {}).filter(d => !whiteListedModules.includes(d))
问题三: cannot find mould bytebuffer
解决方法:
放在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)\videoAudio\test.exe; Flags: CreateValueIfDoesntExist; ValueType: string;
Root: HKCR; SubKey: Cboyi\shell\open\command; ValueData:"C:\Program Files (x86)\videoAudio\test.exe ""%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 or locked.....
解决:
方法一: 关掉360
方法二:如果还是不可以关闭开发工具,直接cmd打开命令行工具执行 yarn run build