在 ubuntu 上构建电子应用程序失败并显示“权限被拒绝”

问题描述 投票:0回答:3

我尝试使用“电子构建器”模块在我的ubuntu系统上构建我的电子项目,但是

npm run dist
总是输出此错误:

> [email protected] dist /home/user/GitRepos/project
> build

sh: 1: build: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! [email protected] dist: `build`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the [email protected] dist script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/user/.npm/_logs/2018-12-03T10_20_50_566Z-debug.log

我已经尝试使用

sudo npm run dist
,因为我假设我的用户可能没有构建所需的权限,但导致了完全相同的错误。

这是我的脚本、依赖项和 linux 构建设置

package.json
:

"scripts": {
  "start": "electron .",
  "pack": "build --dir",
  "dist": "build",
  "postinstall": "install-app-deps"
},
"dependencies": {
  "archiver": "^3.0.0",
  "electron-store": "^2.0.0",
  "popper.js": "^1.14.4",
  "unzipper": "^0.9.4"
},
"devDependencies": {
  "electron": "^3.0.10",
  "electron-builder": "^20.28.4"
},
"build": {
  "linux": {
    "target": [
      "AppImage",
      "deb"
    ]
  }
}

有人对 ubuntu 上的 Electron 有想法或经历过类似的事情吗?

PS:如果需要更多信息,请随时询问!

ubuntu electron building
3个回答
6
投票

尝试重新安装模块:

rm -rf node_modules && npm i

如果没有效果,尝试设置 Electron-builder 脚本的可执行标志:

chmod +x "$(npm bin)/electron-builder"

chmod +x "$(npm bin)/build"
适用于旧版本的电子构建器


0
投票

你也可以尝试一下

rm -rf dist

显然,如果之前有任何文件,可能没有足够的权限。


0
投票

对于那些仍然遇到此问题的人 - 删除 bin 文件夹并再次执行

electronize start /watch
。问题解决了。如果您无权删除 bin 文件夹,则需要执行
chmod 777 ./
chown {youruser} ./
无论如何,这对我有用。

我在 Windows 虚拟机上打开了我的 Nix 项目,这就是为我服务的。 祝你好运。如果这有帮助,请竖起大拇指。

© www.soinside.com 2019 - 2024. All rights reserved.