Error: Cannot find module 'fs/promises'
- 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.
you have any soluction? in my work team we have the same problem, from yesterday we could not compile the project.
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 buildI replace producedresource/app.asarwith 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 changeelectron-updaterfrom^4.3.5to4.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.1exact command line you can see inelectronize buildoutput. - in the last line of the output you will see
appOutDir=...\App\bin\Desktop\win-ia32-unpackedthen you can find yourapp.asarinApp\bin\Desktop\win-ia32-unpacked\resources\app.asar
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 buildI replace producedresource/app.asarwith previously copied good oneHow to create app.asar.
When you call
ecectronize buildyou can see build directory and commands, in my case it'sApp\obj\desktop\custom:
- go to this folder, here you will find
package.json, open it and changeelectron-updaterfrom^4.3.5to4.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.1exact command line you can see inelectronize buildoutput.- in the last line of the output you will see
appOutDir=...\App\bin\Desktop\win-ia32-unpackedthen you can find yourapp.asarinApp\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 :(
Thx frninja
In my opinion, the best way to fix the bug is to regenerate ElectronNet.CLI.
- Clone the repo
- Checkout version 9.31.2
- 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
- Use the buildReleaseNuGetPackages.cmd to regenerate ElectronNet.CLI nuget package. I changed the version to 9.31.3 to facilitate deployement
- Install your new nuget from your local repo and use your favorite electron app generation command again
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.
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
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.
I have fixed this issue by doing following changes to my project
- Upgraded my project from dotnet core 3.1 to dot net 5.0
- Upgraded ElectronNET API from 9.32.1 to 13.5.1
- Upgraded ElectronNET CLI from 9.32.1 to 13.5.1.0
- 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"
}
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!
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:
- Deleted
node_modules - Deleted
package-lock.json - Updated node. I was on Node 12.x and I updated to the latest (16.14.2 as of now)
- Ran
npm install
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.
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.
🎉🚀 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!
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