我正在尝试将我的电子应用程序变成 Windows 便携版

Posted

技术标签:

【中文标题】我正在尝试将我的电子应用程序变成 Windows 便携版【英文标题】:I am trying to turn my electron app to windows portable 【发布时间】:2018-11-27 02:07:06 【问题描述】:

我进行了很多搜索,但没有任何东西真正有助于将我的应用程序构建为可移植的。不管我做什么,结果总是一个 nsis。

它遵循 package.json:

  
  "name": "pvmplayer",
  "version": "1.0.0",
  "description": "",
  "main": "main.js",
  "scripts": 
    "postinstall": "install-app-deps",
    "start": "npm install && electron .",
    "pack": "build --dir",
    "dist": "build"
  ,
  "author": "",
  "license": "ISC",
  "devDependencies": 
    "ajv": "^6.5.1",
    "electron": "^2.0.2",
    "electron-builder": "^20.15.1"
  ,
  "optionalDependencies": ,
  "dependencies": ,
  "electronBuilder": 
    "build": 
      "productName": "PVM Player",
      "appId": "scripter.PVMplayer",
      "win": 
        "target": ["portable"]
      ,
      "directories": 
        "output": "electron/output",
        "app": "electron/app",
        "buildResources": "electron/buildResources"
      
    
  

有什么好的指南可以参考吗?

【问题讨论】:

【参考方案1】:

尝试将"win": "target": ["portable"] "portable": "artifactName": "pvmplayer_portable.exe" 放入"build",可移植文件将创建为pvmplayer_portable.exe


    "name": "pvmplayer",
    "version": "1.0.0",
    "description": "",
    "main": "main.js",
    "scripts": 
        "postinstall": "install-app-deps",
        "start": "npm install && electron .",
        "pack": "build --dir",
        "dist": "build"
    ,
    "author": "",
    "license": "ISC",
    "devDependencies": 
        "ajv": "^6.5.1",
        "electron": "^2.0.2",
        "electron-builder": "^20.15.1"
    ,
    "optionalDependencies": ,
    "dependencies": ,
    "build": 
        "productName": "PVM Player",
        "appId": "scripter.PVMplayer",
        "win": 
            "target": ["portable"]
        ,
        "portable": 
            "artifactName": "pvmplayer_portable.exe"
        ,
        "directories": 
            "output": "electron/output",
            "app": "electron/app",
            "buildResources": "electron/buildResources"
        
    

【讨论】:

您好,您用于构建软件包的命令和库是什么? @LeonardoRick 在 package.json 中我使用electron-builder 进行构建,使用命令npm run dist

以上是关于我正在尝试将我的电子应用程序变成 Windows 便携版的主要内容,如果未能解决你的问题,请参考以下文章

无法在 Windows 上使用电子 4.0.6 加载一些本机节点 js 模块

为啥我的 php 没有将我的联系表单输入发送到我的电子邮件?

PDO SQL 我正在尝试将我的 SQL 查询设置为检查多个列,但它不起作用 [重复]

如何使用 Windows 将我的 Django 项目连接到 MySql?

从本地通知将 iphone 变成 iBeacon

XAMPP 发送邮件无法正常工作