user8715216
user8715216

Reputation: 21

Error when building my electron app

I'm stuck with a problem when building my Node JS/electron app with electron-builder. It works perfectly when running npm start. But, when I execute the command build -w (for windows) it fails with this log.

Here is my JSON file:

{
  "name": "Munshiiii",
  "version": "1.0.0",
  "description": "This is a short Description of the project",
  "main": "index.js",
  "scripts": {
    "start": "electron .",
    "dist": "build -w"
  },
  "author": "Hicham Dbiza",
  "license": "ISC",
  "devDependencies": {
    "electron": "1.7.8",
    "electron-prebuilt": "^1.4.13"
  },
  "dependencies": {
    "asar": "^0.13.0",
    "cradle": "^0.7.1",
    "fs": "0.0.1-security",
    "git": "^0.1.5",
    "jquery": "^3.2.1",
    "jsdom": "^11.3.0",
    "loke-ipc": "^1.0.5",
    "mongodb": "^2.2.33",
    "node-couchdb": "^1.2.0",
    "pouchdb": "^6.3.4",
    "pouchdb-replication-stream": "^1.2.9",
    "scanner.js": "^1.0.0"
  },
  "build":{
    "appId": "com.hicham.dbiza.faizan",
    "win":{
        "target": "nsis",
        "icon": "build/Munshiiii.ico"
    }
  }
}

for this project Im using:

I already used electron-packager and it works almost fine with one problem: See this picture, which means all links inside the js files (e.g: fs.readFileSync('./assets/state','utf8')) won't work. I have also added some native js click and keypress listeners... could that be a problem?

My electron version is 1.7.8.

I appreciate your help.

Upvotes: 2

Views: 16016

Answers (4)

zaid nagori
zaid nagori

Reputation: 21

I've encountered a similar issue where my app runs perfectly during development but throws an error during the build process, specifically:

ERROR: Cannot create symbolic link: A required privilege is not held by the client.

Here's what worked for me:

  • Try using Yarn instead of npm: While this didn't resolve the issue for me, it might work for others.

  • Enable Developer Mode on Windows:

  • This error often occurs because Windows doesn't allow the creation of symbolic links unless you have the necessary privileges.

  • To enable Developer Mode, go to Settings > System > for Developers > Developer Mode > switch Developer mode On. (for window 11)

Upvotes: 0

Soumitya Chauhan
Soumitya Chauhan

Reputation: 367

Yarn is strongly recommended instead of npm.

yarn add electron-builder --dev

if you are using Npm
do just simple steps terminal:

1 npm install yarn -g
2 yarn
3 yarn pack

Read this Blog (reactJS in electronApp with .exe file)

Upvotes: 1

Pawana
Pawana

Reputation: 296

First I installed electron-builder with following line

npm install -g electron-builder

then I created a build folder in the root of my project, containing the .ico file with the app logo. then I wrote following parts in my package.json

"build": {
"appId": "your.app.id",
"productName": "Your final product name"
}

and

"scripts": {
"start": "electron .",
"pack": "build --dir"
}

That was everything I needed. I opend my root folder in the terminal and executed

build -w

That created an folder called dist, with an unpacked version of my app plus an installer for the app.

Upvotes: 0

kontrollanten
kontrollanten

Reputation: 2819

Have you installed electron-builder? You don't have it in your package.json. Then I would propose to use the electron-builder command, as recommended by the authors.

Run npm install electron-builder --save-dev and change your dist command to run just electron-builder. Since electron-builder per default build for the current running OS, it's not necessary to send the -w flag. If you still experience problems, try to set the following env variable to get a better stack trace:

DEBUG=electron-builder,electron-builder:*

Edit after getting more information from the comments: According to this issue at GitHub your first issue seemed to be caused by permission errors, and was solved with running as administrator.

From electron-builders README:

Yarn is strongly recommended instead of npm.

yarn add electron-builder --dev

Try to remove your node_modules folder and run

npm install yarn -g && yarn && yarn pack

Upvotes: 0

Related Questions