3

I tried building my electron project on my ubuntu system using the 'electron-builder' module, but npm run dist always outputs this error:

> 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

I already tried using sudo npm run dist, since I assumed my user might just had not the required permissions for building, but is caused the exact same error.

Here are my scripts, dependencies and linux build settings from my 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"
    ]
  }
}

Anyone got an idea or has experienced a similar thing with electron on ubuntu?

P.S: If more information is needed, don't hesitate to ask!

Julian Z.
  • 487
  • 6
  • 11

2 Answers2

5

Try to reinstall modules:

rm -rf node_modules && npm i

If it has no effect, try to set executable flag of electron-builder script:

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

or

chmod +x "$(npm bin)/build" for old version of electron-builder

Alexey Prokhorov
  • 3,431
  • 1
  • 22
  • 25
  • First of all, thanks for the answer. The reinstall worked 'a bit'. It actually started building, but now it fails while doing so. `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 ⨯ EOF` and `Error: /home/user/GitRepos/project/node_modules/app-builder-bin/linux/x64/app-builder exited with code 1` any other ideas? I set the executable flag of all the contents of the build folder and its contents already. – Julian Z. Dec 03 '18 at 14:00
  • 2
    Actually, it's the next problem and I recommend you to create another question for it. But, the short answer: just add all fields of package.json required by electron-builder according to documentation. – Alexey Prokhorov Dec 03 '18 at 18:23
  • True. Since your answer solves the specific problem from my first question above, I marked it as the answer! – Julian Z. Dec 04 '18 at 07:30
  • edit: You were right, there was just something missing in the `package.json`. It successfull builded now! – Julian Z. Dec 04 '18 at 07:41
  • `rm -rf node_modules && npm i` didn't fix my problem. I still get 126 error. I'm using default electron example on ubuntu 18.4. – Alireza Dec 22 '18 at 18:39
  • @Alireza Akrami It seems that you have another problem. So it's better to create another question with your logs and package.json attached. – Alexey Prokhorov Dec 23 '18 at 05:38
0

You may also try

rm -rf dist

As apparently there might not be sufficient permission if there were any files previously.

Antonin GAVREL
  • 9,682
  • 8
  • 54
  • 81