zoukankan      html  css  js  c++  java
  • electron 打包成exe两种方式,以及常见问题

    {
      "name": "electron-quick-start",
      "version": "1.0.0",
      "description": "A minimal Electron application",
      "main": "main.js",
      "scripts": {
        "start": "electron .",
        "win": "electron-packager . Bcreat --platform=win32 --arch=x64 --icon=icon.ico --out=./dlist --asar --app-version=0.0.1",
        "winexe": "electron-builder --win --x64"
      },
      "repository": "https://github.com/electron/electron-quick-start",
      "keywords": [
        "Electron",
        "quick",
        "start",
        "tutorial",
        "demo"
      ],
      "build": {
        "appId": "com.bcreatexe.app",
        "nsis": {
          "oneClick": false,
          "allowElevation": true,
          "allowToChangeInstallationDirectory": true,
          "installerIcon": "./icon.ico",
          "uninstallerIcon": "./icon.ico",
          "installerHeaderIcon": "./icon.ico",
          "createDesktopShortcut": true,
          "createStartMenuShortcut": true
        },
        "win": {
          "target": "nsis"
        }
      },
      "author": "GitHub",
      "license": "CC0-1.0",
      "devDependencies": {
        "electron-builder": "^22.10.5",
        "electron": "^12.0.5"
      },
      "dependencies": {
        "electron-packager": "^15.2.0"
      }
    }

    将上面代码修改根目录package.json文件,注意你改成你自己的项目名称~

    常用electron打包方式分两种

    一、electron-packager

    含义就打包成直接运行包,可以直接打开exe运行

    二、electron-builder

    含义就是打包成安装版,可以自定义安装路径,安装图标,创建桌面快捷方式等,运行exe,打开开始安装

    运行方式:npm run win  (就是运行electron-packager打包方式)、npm  run winexe (就是运行electron-builder打包方式),具体的代码在上面代码scripts参数里面~

  • 相关阅读:
    WebBrowser Control(三)Privacy Alert对话框
    工具栏添加控件
    OpenGL(一)Introduction
    WebBrowser Control(四)URL Security Zones
    OpenGL(二)三维变换
    STL(二)Iterators
    string与wstring转换
    vs2005制作安装包
    唉,又是数组越界的问题!
    CString之GetBuffer、ReleaseBuffer
  • 原文地址:https://www.cnblogs.com/feimengv/p/14721554.html
Copyright © 2011-2022 走看看