Error: Cannot find module 'fs/promises' #725

Closed
opened 2026-01-29 16:46:52 +00:00 by claunia · 14 comments
Owner

Originally created by @Cedric-LE on GitHub (Nov 25, 2021).

Originally assigned to: @GregorBiswanger on GitHub.

  • Electron.NET CLI 9.31.2
  • Node version v14.17.6
  • Dotnet core 3.1
  • electron-builder 22.14.5
  • Windows 10

I have been building an application with Electron.NET for several years that works well. Recently, I rebuilt the application successfully but when I launch the app, I get the following error message in a popup:

Error: Cannot find module 'fs/promises'
Stack:
...\AppUpdater.js
...\main.js
...\autoUpdater.js

I can't use the file browser or access the dev tools of the app.

I can't solve my problem. I tried to use older versions of electron builder, 22.10.5 in particular by installing it globally, but this does not solve my bug.

I went back to the package.json of my application at a point where I was sure that it worked, but I still have this problem. I regenerated the lock package, removed the node_modules, reinstalled node js 14.17.1.

I'm going in circles. I don't know how to debug this problem.

Originally created by @Cedric-LE on GitHub (Nov 25, 2021). Originally assigned to: @GregorBiswanger on GitHub. * Electron.NET CLI 9.31.2 * Node version v14.17.6 * Dotnet core 3.1 * electron-builder 22.14.5 * Windows 10 I have been building an application with Electron.NET for several years that works well. Recently, I rebuilt the application successfully but when I launch the app, I get the following error message in a popup: Error: Cannot find module 'fs/promises' Stack: ...\AppUpdater.js ...\main.js ...\autoUpdater.js I can't use the file browser or access the dev tools of the app. I can't solve my problem. I tried to use older versions of electron builder, 22.10.5 in particular by installing it globally, but this does not solve my bug. I went back to the package.json of my application at a point where I was sure that it worked, but I still have this problem. I regenerated the lock package, removed the node_modules, reinstalled node js 14.17.1. I'm going in circles. I don't know how to debug this problem.
claunia added the bug label 2026-01-29 16:46:52 +00:00
Author
Owner

@izakntun commented on GitHub (Nov 26, 2021):

you have any soluction? in my work team we have the same problem, from yesterday we could not compile the project.

@izakntun commented on GitHub (Nov 26, 2021): you have any soluction? in my work team we have the same problem, from yesterday we could not compile the project.
Author
Owner

@nyxiscoo1 commented on GitHub (Nov 26, 2021):

you have any soluction? in my work team we have the same problem, from yesterday we could not compile the project.

We can compile, but when it starts error message box appears.
I fixed it in the following way:

  • manually built electron with fixed, as in frninja commit, package.json(instructions below)
  • copy resource/app.asar
  • after electronize build I replace produced resource/app.asar with previously copied good one

How to create app.asar.

When you call ecectronize build you can see build directory and commands, in my case it's App\obj\desktop\custom:

  • go to this folder, here you will find package.json, open it and change electron-updater from ^4.3.5 to 4.3.9
  • then run npm install --production
  • after it successfully completes run npx electron-builder --config=./bin/electron-builder.json --win --ia32 -c.electronVersion=11.1.1 exact command line you can see in electronize build output.
  • in the last line of the output you will see appOutDir=...\App\bin\Desktop\win-ia32-unpacked then you can find your app.asar in App\bin\Desktop\win-ia32-unpacked\resources\app.asar
@nyxiscoo1 commented on GitHub (Nov 26, 2021): > you have any soluction? in my work team we have the same problem, from yesterday we could not compile the project. We can compile, but when it starts error message box appears. I fixed it in the following way: - manually built electron with fixed, as in frninja commit, `package.json`(instructions below) - copy `resource/app.asar` - after `electronize build` I replace produced `resource/app.asar` with previously copied good one ### How to create app.asar. When you call `ecectronize build` you can see build directory and commands, in my case it's `App\obj\desktop\custom`: - go to this folder, here you will find `package.json`, open it and change `electron-updater` from `^4.3.5` to `4.3.9` - then run `npm install --production` - after it successfully completes run `npx electron-builder --config=./bin/electron-builder.json --win --ia32 -c.electronVersion=11.1.1` exact command line you can see in `electronize build` output. - in the last line of the output you will see `appOutDir=...\App\bin\Desktop\win-ia32-unpacked` then you can find your `app.asar` in `App\bin\Desktop\win-ia32-unpacked\resources\app.asar`
Author
Owner

@izakntun commented on GitHub (Nov 26, 2021):

you have any soluction? in my work team we have the same problem, from yesterday we could not compile the project.

We can compile, but when it starts error message box appears. I fixed it in the following way:

  • manually built electron with fixed, as in frninja commit, package.json(instructions below)
  • copy resource/app.asar
  • after electronize build I replace produced resource/app.asar with previously copied good one

How to create app.asar.

When you call ecectronize build you can see build directory and commands, in my case it's App\obj\desktop\custom:

  • go to this folder, here you will find package.json, open it and change electron-updater from ^4.3.5 to 4.3.9
  • then run npm install --production
  • after it successfully completes run npx electron-builder --config=./bin/electron-builder.json --win --ia32 -c.electronVersion=11.1.1 exact command line you can see in electronize build output.
  • in the last line of the output you will see appOutDir=...\App\bin\Desktop\win-ia32-unpacked then you can find your app.asar in App\bin\Desktop\win-ia32-unpacked\resources\app.asar

this solution is good for to do the executable file, but isn't our case because this problem occurs when run electronize start :(

@izakntun commented on GitHub (Nov 26, 2021): > > you have any soluction? in my work team we have the same problem, from yesterday we could not compile the project. > > We can compile, but when it starts error message box appears. I fixed it in the following way: > > * manually built electron with fixed, as in frninja commit, `package.json`(instructions below) > * copy `resource/app.asar` > * after `electronize build` I replace produced `resource/app.asar` with previously copied good one > > ### How to create app.asar. > When you call `ecectronize build` you can see build directory and commands, in my case it's `App\obj\desktop\custom`: > > * go to this folder, here you will find `package.json`, open it and change `electron-updater` from `^4.3.5` to `4.3.9` > * then run `npm install --production` > * after it successfully completes run `npx electron-builder --config=./bin/electron-builder.json --win --ia32 -c.electronVersion=11.1.1` exact command line you can see in `electronize build` output. > * in the last line of the output you will see `appOutDir=...\App\bin\Desktop\win-ia32-unpacked` then you can find your `app.asar` in `App\bin\Desktop\win-ia32-unpacked\resources\app.asar` this solution is good for to do the executable file, but isn't our case because this problem occurs when run `electronize start` :(
Author
Owner

@Cedric-LE commented on GitHub (Nov 29, 2021):

Thx frninja

In my opinion, the best way to fix the bug is to regenerate ElectronNet.CLI.

  1. Clone the repo
  2. Checkout version 9.31.2
  3. Patch the package.json of ElectronNET.Host by pinning the version of electron-updater to 4.3.9. Other versions should work. I also fixed the versions of the other packages to avoid new surprises
  4. Use the buildReleaseNuGetPackages.cmd to regenerate ElectronNet.CLI nuget package. I changed the version to 9.31.3 to facilitate deployement
  5. Install your new nuget from your local repo and use your favorite electron app generation command again
@Cedric-LE commented on GitHub (Nov 29, 2021): Thx frninja In my opinion, the best way to fix the bug is to regenerate ElectronNet.CLI. 1. Clone the repo 2. Checkout version 9.31.2 3. Patch the package.json of ElectronNET.Host by pinning the version of electron-updater to 4.3.9. Other versions should work. I also fixed the versions of the other packages to avoid new surprises 4. Use the buildReleaseNuGetPackages.cmd to regenerate ElectronNet.CLI nuget package. I changed the version to 9.31.3 to facilitate deployement 5. Install your new nuget from your local repo and use your favorite electron app generation command again
Author
Owner

@jim-lin507 commented on GitHub (Dec 1, 2021):

For Electron.NET 9.31.2, I uninstalled ElectronNet.CLI 9.31.2, then installed ElectronNet.CLI 13.5.1. It works for me so far.

But if the specific version of electron-builder can be used during building, it would be able to solve the root issue.

@jim-lin507 commented on GitHub (Dec 1, 2021): For Electron.NET 9.31.2, I uninstalled ElectronNet.CLI 9.31.2, then installed ElectronNet.CLI 13.5.1. It works for me so far. But if the specific version of electron-builder can be used during building, it would be able to solve the root issue.
Author
Owner

@vsmike commented on GitHub (Dec 1, 2021):

I am also getting errors and need help. I can run electronize start with no issues, but when running the executable I get this error as well. Please help. I plan to try the above workaround for now, [Did not work]. BLOCKED
Electron.NET API 15.3.1
Node version v17.2.0
Dotnet core 5.0
electron-builder 22.14.5
Windows 11

@vsmike commented on GitHub (Dec 1, 2021): I am also getting errors and need help. I can run electronize start with no issues, but when running the executable I get this error as well. Please help. I plan to try the above workaround for now, [Did not work]. BLOCKED Electron.NET API 15.3.1 Node version v17.2.0 Dotnet core 5.0 electron-builder 22.14.5 Windows 11
Author
Owner

@vsmike commented on GitHub (Dec 1, 2021):

Ok I was able to get it working...I upgraded package.json in the following way.
"electron-updater": "4.6.1"
"electron": "^16.0.3",
And following Cedric-LE example. I ran "buildAll" instead of buildReleaseNuGetPackages.cmd. I will update to the latest electron build.

@vsmike commented on GitHub (Dec 1, 2021): Ok I was able to get it working...I upgraded package.json in the following way. "electron-updater": "4.6.1" "electron": "^16.0.3", And following Cedric-LE example. I ran "buildAll" instead of buildReleaseNuGetPackages.cmd. I will update to the latest electron build.
Author
Owner

@rajeshs-logicmatter commented on GitHub (Dec 5, 2021):

I have fixed this issue by doing following changes to my project

  1. Upgraded my project from dotnet core 3.1 to dot net 5.0
  2. Upgraded ElectronNET API from 9.32.1 to 13.5.1
  3. Upgraded ElectronNET CLI from 9.32.1 to 13.5.1.0
  4. Modified package.json dependencies and devDependencies to below
"dependencies": {
   "electron-updater": "4.3.9",
   "image-size": "1.0.0",
   "portscanner": "^2.2.0",
   "socket.io": "^2.4.0",
   "dasherize": "2.0.0"
 },
 "devDependencies": {
   "@types/node": "^15.14.0",
   "electron": "^13.1.5",
   "tslint": "^6.1.3",
   "typescript": "^4.3.5"
 }
@rajeshs-logicmatter commented on GitHub (Dec 5, 2021): I have fixed this issue by doing following changes to my project 1. Upgraded my project from dotnet core 3.1 to dot net 5.0 2. Upgraded ElectronNET API from 9.32.1 to 13.5.1 3. Upgraded ElectronNET CLI from 9.32.1 to 13.5.1.0 4. Modified package.json **dependencies** and **devDependencies** to below ``` "dependencies": { "electron-updater": "4.3.9", "image-size": "1.0.0", "portscanner": "^2.2.0", "socket.io": "^2.4.0", "dasherize": "2.0.0" }, "devDependencies": { "@types/node": "^15.14.0", "electron": "^13.1.5", "tslint": "^6.1.3", "typescript": "^4.3.5" } ```
Author
Owner

@yshulin commented on GitHub (Dec 8, 2021):

Ok I was able to get it working...I upgraded package.json in the following way. "electron-updater": "4.6.1" "electron": "^16.0.3", And following Cedric-LE example. I ran "buildAll" instead of buildReleaseNuGetPackages.cmd. I will update to the latest electron build.

Yes, I just only upgraded electron-updater to 4.3.9 and ran "buildAll.cmd", It works fine!
Thanks a lot!

@yshulin commented on GitHub (Dec 8, 2021): > Ok I was able to get it working...I upgraded package.json in the following way. "electron-updater": "4.6.1" "electron": "^16.0.3", And following Cedric-LE example. I ran "buildAll" instead of buildReleaseNuGetPackages.cmd. I will update to the latest electron build. Yes, I just only upgraded electron-updater to 4.3.9 and ran "buildAll.cmd", It works fine! Thanks a lot!
Author
Owner

@sarrascaeta commented on GitHub (Apr 13, 2022):

I was getting this issue too, running the build /target win command. There's a lot of potential fixes here, but my fix was very simple, and maybe it shines some light on the bug.

Steps:

  1. Deleted node_modules
  2. Deleted package-lock.json
  3. Updated node. I was on Node 12.x and I updated to the latest (16.14.2 as of now)
  4. Ran npm install
@sarrascaeta commented on GitHub (Apr 13, 2022): I was getting this issue too, running the `build /target win` command. There's a lot of potential fixes here, but my fix was very simple, and maybe it shines some light on the bug. ### Steps: 1. Deleted `node_modules` 2. Deleted `package-lock.json` 3. Updated node. I was on Node 12.x and I updated to the latest (16.14.2 as of now) 4. Ran `npm install`
Author
Owner

@Liam2349 commented on GitHub (Apr 20, 2022):

Hi, I've tried every solution in here and I still get this error, both when running the built Windows .exe and when running "electronize start".

I've encountered this before and found that upgrading Node.js resolved it, but not this time.

Is it possible to just remove this electron-updater? I don't use it in my own code.

Currently unable to release any builds.

@Liam2349 commented on GitHub (Apr 20, 2022): Hi, I've tried every solution in here and I still get this error, both when running the built Windows .exe and when running "electronize start". I've encountered this before and found that upgrading Node.js resolved it, but not this time. Is it possible to just remove this electron-updater? I don't use it in my own code. Currently unable to release any builds.
Author
Owner

@Liam2349 commented on GitHub (Apr 20, 2022):

I did more testing and what worked for me was setting ElectronNET.Host's package.json to electron-updater 4.6.1 and electron ^16.0.3, running buildAll.cmd, running buildReleaseNuGetPackages.cmd, and using that new API package. The buildAll installs the CLI package. This was vsmike's suggestion.

Other steps I took before reaching this fix:

Tested my project in a clean virtual machine and this error still occurs, so it's not an environment issue.

My regular desktop that produces this error is running Windows 10, the VM runs Windows 11.

I have tried setting electron-updater in my project's package.json to 4.3.9. I have tried doing it in ElectronNET.Host's package.json and then running buildAll.cmd to install this new CLI version.

I've used buildReleaseNuGetPackages.cmd and used this new API NuGet package with my project.

I've deleted every node_modules and package-lock.json file in my project, then ran "npm install" or "npm install --production".

I've tried using the 13.5.1 versions of the CLI and API.

I've cleaned and rebuilt my solution.

@Liam2349 commented on GitHub (Apr 20, 2022): I did more testing and what worked for me was setting ElectronNET.Host's package.json to electron-updater 4.6.1 and electron ^16.0.3, running buildAll.cmd, running buildReleaseNuGetPackages.cmd, and using that new API package. The buildAll installs the CLI package. This was [vsmike](https://github.com/vsmike)'s suggestion. Other steps I took before reaching this fix: Tested my project in a clean virtual machine and this error still occurs, so it's not an environment issue. My regular desktop that produces this error is running Windows 10, the VM runs Windows 11. I have tried setting electron-updater in my project's package.json to 4.3.9. I have tried doing it in ElectronNET.Host's package.json and then running buildAll.cmd to install this new CLI version. I've used buildReleaseNuGetPackages.cmd and used this new API NuGet package with my project. I've deleted every node_modules and package-lock.json file in my project, then ran "npm install" or "npm install --production". I've tried using the 13.5.1 versions of the CLI and API. I've cleaned and rebuilt my solution.
Author
Owner

@GregorBiswanger commented on GitHub (Mar 28, 2023):

🎉🚀 New Electron.NET version 23.6.1 released 🚀🎉

With native Electron 23 and .NET 6 support. Your problem should be fixed here. If you continue to have the problem, please let us know. Please note the correct updating of your API & CLI. Info in the README. Have fun!

@GregorBiswanger commented on GitHub (Mar 28, 2023): 🎉🚀 New Electron.NET version 23.6.1 released 🚀🎉 With native Electron 23 and .NET 6 support. Your problem should be fixed here. If you continue to have the problem, please let us know. Please note the correct updating of your API & CLI. Info in the README. Have fun!
Author
Owner

@mahesh-kockpit commented on GitHub (Apr 14, 2023):

rajeshs-logicmatter
Thank you ,
I am also facing this kind of issue but as you suggested the steps I followed them and everything working smoothly

Solution:

  • Install SDK .Net 5.0
  • Install ElectronNET.CLI --version 13.5.1
    Command : dotnet tool install --global ElectronNET.CLI --version 13.5.1

That's it

@mahesh-kockpit commented on GitHub (Apr 14, 2023): > rajeshs-logicmatter Thank you , I am also facing this kind of issue but as you suggested the steps I followed them and everything working smoothly Solution: - Install SDK .Net 5.0 - Install ElectronNET.CLI --version 13.5.1 Command : dotnet tool install --global ElectronNET.CLI --version 13.5.1 That's it
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#725