【问题标题】:Building electron app on ubuntu fails with 'Permission denied'在 ubuntu 上构建电子应用程序失败并显示“权限被拒绝”
【发布时间】:2020-12-02 10:26:59
【问题描述】:

我尝试使用'electron-builder'模块在我的ubuntu系统上构建我的电子项目,但npm run dist总是输出这个错误:

> project@1.0.0 dist /home/user/GitRepos/project
> build

sh: 1: build: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! project@1.0.0 dist: `build`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the project@1.0.0 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,因为我认为我的用户可能只是没有构建所需的权限,但却导致了完全相同的错误。

这是我的 package.json 中的脚本、依赖项和 linux 构建设置:

"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 上使用电子遇到过类似的事情?

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

【问题讨论】:

    标签: ubuntu electron building


    【解决方案1】:

    尝试重新安装模块:

    rm -rf node_modules && npm i

    如果无效,尝试设置electron-builder脚本的可执行标志:

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

    chmod +x "$(npm bin)/build" 旧版电子生成器

    【讨论】:

    • 首先,感谢您的回答。重新安装“有点”。它实际上开始构建,但现在它在这样做时失败了。 application Linux category is set to default "Utility" reason=linux.category is not set and cannot map from macOS docs=https://electron.build/configuration/configuration#LinuxBuildOptions-category ⨯ EOFError: /home/user/GitRepos/project/node_modules/app-builder-bin/linux/x64/app-builder exited with code 1 还有其他想法吗?我已经设置了构建文件夹及其内容的所有内容的可执行标志。
    • 其实,这是下一个问题,我建议您为它创建另一个问题。但是,简短的回答:只需根据文档添加电子生成器所需的 package.json 的所有字段。
    • 是的。由于您的回答解决了我上面第一个问题的具体问题,所以我将其标记为答案!
    • edit:你是对的,package.json 中只是缺少一些东西。现在已经成功构建了!
    • rm -rf node_modules && npm i 没有解决我的问题。我仍然收到 126 错误。我在 ubuntu 18.4 上使用默认电子示例。
    【解决方案2】:

    你也可以试试

    rm -rf dist
    

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

    【讨论】:

      猜你喜欢
      • 2019-09-14
      • 2012-08-27
      • 2013-12-10
      • 2020-12-26
      • 2020-02-14
      • 2023-01-18
      • 2021-08-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多