我正在尝试为我的电子应用创建一个窗口安装程序(以便它可以在任何Windows计算机上作为独立应用程序运行),使用电子构建器https://www.npmjs.com/package/electron-builder
在我的计算机上键入npm run dist
时,我遇到以下错误。
sh: 1: build: not found
npm ERR! Linux 3.4.0+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dist"
npm ERR! node v6.2.2
npm ERR! npm v3.9.5
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! <NAME>@0.0.0 dist: `build`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the <NAME>@0.0.0 dist script 'build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the <NAME>,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! build
以下是我的package.json文件的外观
{
"name": "<NAME>",
"version": "0.0.0",
"description": "[...]",
"main": "index.js",
"build": {
"appId": "test.321",
"app-category-type": "your.app.category.type",
"win": {
"iconUrl": "http://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon.png"
}
},
"scripts": {
"start": "electron main.js",
"postinstall": "install-app-deps",
"pack": "build --dir",
"dist": "build"
},
"author": "<NAME> <jon@gmail.com>",
"license": "ISC",
"devDependencies": {
"electron": "^1.3.3",
"electron-installer-squirrel-windows": "^1.3.0",
"electron-packager": "^7.5.1"
}
}
我正在使用Windows 10,并通过bash执行命令
答案 0 :(得分:4)
我遵循this blogpost来构建它,但我遇到了同样的问题,我解决了该问题,用build
命令替换了electron-builder
并删除了过时的category
字段名称。 / p>
"scripts": {
"postinstall": "install-app-deps",
"start": "npm install && electron .",
"test": "echo \"Error: no test specified\" && exit 1",
"pack": "electron-builder --dir",
"dist": "electron-builder"
},