node.js - 我正在尝试将我的 Electron 应用程序转换为 windows portable

标签 node.js electron electron-builder

我搜索了很多,但没有任何东西真正有助于将我的应用程序构建为可移植的。无论我做什么,结果总是 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"
      }
    }
  }
}

有什么好的指南可以遵循吗?

最佳答案

尝试放置 "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"
        }
    }
}

关于node.js - 我正在尝试将我的 Electron 应用程序转换为 windows portable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50905886/

相关文章:

javascript - 获取Mac中所有可见应用程序窗口进程的窗口标题和应用程序/进程名称

node.js - 对于Mac,基于 Electron 的应用程序卸载是否发生事件?还是区分安装和更新的方法?

javascript - node.js 从 html 输入值

node.js - -bash : npm: command not found, 为什么?

javascript - 如何在使用 Passport.js 成功登录后刷新用户的用户名?

javascript - NodeJS - Events.js 无法读取未定义的每个属性

node.js - 从客户端*桌面* Meteor 应用程序读取/写入/浏览文件?

angular - 如何用 Electron 外部化文件夹?

node.js - 有没有一种方法可以打包Electron应用程序,以使其具有.exe文件和仅包含HTML/JS/CSS文件的文件夹?

node.js - Electron如何确定requestSingleInstanceLock的应用程序身份?