Cannot Find Module 'Fs/Promises' Electron Js

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:

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

1

7 Answers

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.
1

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

2

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

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

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

0

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.

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

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)

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest