【问题标题】:I am trying to turn my electron app to windows portable我正在尝试将我的电子应用程序变成 Windows 便携版
【发布时间】: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"
      }
    }
  }
}

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

【问题讨论】:

    标签: node.js electron electron-builder


    【解决方案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
    猜你喜欢
    • 2019-08-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-05
    • 1970-01-01
    • 1970-01-01
    • 2018-09-23
    相关资源
    最近更新 更多