23

Good morning,

I have created a program in Vue JS, this connects with an API that I have created in a main.js file to execute system commands.

The problem I have is that when compiling for production with electron I get the following error:

ERROR

I use the command npm run electron: build

When I use npm run electron:serve work without problems

Anyone have any idea why is the error and how to fix it? Thanks

csharpbd
  • 3,266
  • 4
  • 21
  • 30
stillborn1
  • 337
  • 1
  • 2
  • 8

7 Answers7

24

I experienced this issue a few days ago as well. I realized that trying to fix another issue, I deleted the node_modules folder and the package-lock.json file, then run the npm install command. This made the build to fail with 'fs/promises'. There are 2 solutions to this issue:

  1. Download the latest stable Node version. This should have the 'fs/promises' module and will fix the issue.
  2. Delete the node_modules folder and bring back the old package-lock.json file to ensure that the package versions remain the same. Then run the npm install command and the issue should be fixed.
  • Hey there, I did upgrade my NodeJS version and worked for me, I used terminal commands in order to upgrade in a faster way, you can follow the instructions here: https://stackoverflow.com/questions/8191459/how-do-i-update-node-js. Take into consideration that maybe other projects you have are incompatible with this new version you are installing, in that case, consider using NVM. – Peter Palmer Nov 21 '21 at 15:56
22

downgrade electron "electron-builder": "^22.10.5", or upgrade nodejs to 14+ v

  • Downgrading the electron-builder version worked for me, with node 12.18.4. This should be the accepted answer since retrieving old package-lock.json is not going to work when installing everything first time. – Boat Sep 20 '21 at 09:50
  • Upgrading to node v14 worked for me. Thanks! – Meekohi Oct 08 '21 at 21:00
10

downgrade to "electron-builder": "~22.10.5" is working for me

Hieu Nguyen
  • 101
  • 2
4

In that case i fix the problem in that way: const fs = require('fs').promises;

instead of: const fs = require('fs/promises');

gBall
  • 41
  • 1
3

In my case I was using nvm to manage multiple node versions.

During the npm package installation, and throughout development, I used Node v14 but for some reason, my terminal was pointing to Node v12 when I tried bundling my program afterwards.

Switching it back to Node v14 using nvm use 14 solved my issue.

So make sure you're using the correct node version.

Cels
  • 845
  • 12
  • 21
0

I had the same problem, after upgrading the electron-builder from v. 21.4.0 to 23.0.2, updated with the command:   sudo npm install -g electron-builder@23.0.2

I solved updating npm, and then node.js.

  1. Update npm:

    sudo npm install -g npm@latest  

  2. Install nodejs from https://nodejs.org

Now it works with :  

  • Electron-builder: 23.0.2 (command electron-builder --version)
  • Npm: 8.7.0 (command npm --version)
  • Nodejs: v16.15.0 (command node --version)
Enzo Degraeve
  • 110
  • 1
  • 9
Paul
  • 267
  • 2
  • 14
0

Upgrade to electron-updater@5.0.0. It has patch changes replacing fs/promises with fs-extra to support legacy versions of electron.

Erich
  • 2,071
  • 13
  • 32
B4Le
  • 41
  • 1