Electron构建、打包总结

提示:Application entry file "main.js" does not exist

解决: package.json中的build模块,添加files

1"files": [ 2 "./index.html", 3 "./main.js", 4 "./package.json", 5 ],

提示:Application entry file "build/electron.js" does not exist

解决: package.json中的build模块添加:

extends: null

网络原因导致没法下载依赖包(win10)

11.electron-v2.0.18-win32-x64.zip 22.SHASUMS256.txt-2.0.18 33.winCodeSign-2.4.0 44.nsis-3.0.3.2 55.nsis-resources-3.3.0

不同版本所需要包不同,应该按提示手动下载 如: https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-resources-3.4.1/nsis-resources-3.4.1.7z

然后放到指定目录 参考

打包后运行exe(win10)

提示can not find module 'electron-is-dev' can not find module 'devtron'

解决:dependencies添加electron-is-dev

TODO: 这一步还需要优化

打包无法找到别名

1.\src\router\index.js 2Cannot find module: '@views/Login/'. Make sure this package is installed.

解决:

1// package.json 2"build": "react-scripts build", 3// 更新为 4"build": "react-app-rewired build",

npm install时,node install卡住

解决: node install.js

1vi ~/.npmrc 2添加: 3electron_mirror="https://npm.taobao.org/mirrors/electron/" 4ELECTRON_MIRROR="https://npm.taobao.org/mirrors/electron/"

运行提示 TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined

更新 "react-scripts": "3.4.0",

重新install

参考

安装依赖包时提示: UnhandledPromiseRejectionWarning: HTTPError: Response code 404 (Not Found) for http://npm.taobao.org/mirrors/electron/v8.0.1/electron-v8.0.1-darwin-x64.zip

以及npm run dev时提示 Electron failed to install correctly, please delete node_modules/electron and try installing again 解决:

1// cnpm下载electron 2rm -rf node_modules/electron // 删除electron包 不然运行会提示包不对 3// 再用cnpm下载electron 4npm install -g cnpm --registry=https://registry.npm.taobao.org 5cnpm i // 下载electron正确包 6 7 8

构建后 打开 dist/index.html空白

解决: BrowserRouter => HashRouter

运行提示× TypeError: window.require is not a function

解决:

  1. BrowserWindow中添加

    webPreferences: { nodeIntegration: true, preload: __dirname + '/preload.js' },

  2. 添加preload.js

    window.ipcRenderer = require('electron').ipcRenderer;

  3. react组件引入ipcRenderer

    import { IpcRenderer } from 'electron';

    declare global { interface Window { ipcRenderer: IpcRenderer } }

    const { ipcRenderer } = window; console.log(ipcRenderer)

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )