Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

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

like image 941
stillborn1 Avatar asked Jun 22 '21 14:06

stillborn1


2 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.
like image 124
Ion-Alexandru Secara Avatar answered Oct 21 '22 10:10

Ion-Alexandru Secara


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

like image 22
Роман Зыков Avatar answered Oct 21 '22 08:10

Роман Зыков