0

I try to build my electron project to window app by using electron-packager but I get this error.

Failed to locate module "fsevents" from "/var/www/windowapp/electron-angular-project/node_modules/@angular-devkit/core/node_modules/chokidar"

    This normally means that either you have deleted this package already somehow (check your ignore settings if using electron-packager).  Or your module installation failed.

Anyone know how to solve it and what happened to this?

Jim
  • 171
  • 4
  • 14

4 Answers4

6

Here my 2 cent, I did a package that works without the error, but also avoids to add unnecessary files:

electron-packager . --no-prune --ignore=/node_modules --ignore=/e2e --ignore=/src

The electron-packager expect that you have already run run the angular build process:

ng build --prod

You can add this script in the package.json:

"electron-package": "ng build --prod && electron-packager . --no-prune --ignore=/node_modules --ignore=/e2e --ignore=/src --overwrite"

Then run:

npm run electron-package
Michael Denny
  • 906
  • 5
  • 12
1

With slight modification on the answer provided by Michael Denny "electron-package": "ng build --prod && electron-packager . --no-prune --ignore=/node_modules --ignore=/e2e --ignore=/src --overwrite" I'm able to package my electron angular 7 application. Please note, minor modifications might require on these commands, on a case to case to basis. In my case, the following command worked.

"electron-package": "ng build --prod --base-href ./ && electron-packager . --no-prune --ignore=/e2e --ignore=/src --overwrite"

What is the change?

Removed --ignore=/node_modules
Reason: if I add this option while building, Ended up in Module Not Found Error

Added --base-href ./
Reason: Otherwise, Ended up with error Failed to load resource: net::ERR_FILE_NOT_FOUND

With these two modifications, I'm able to package my electron angular 7 application. Size of the package is close to 100MB. I'm looking for a way to reduce this size.

Jacob Nelson
  • 2,370
  • 23
  • 35
0

In the directory where your app is, try run this command

electron-packager . --no-prune

More information about this commands can be found in here https://github.com/electron-userland/electron-packager/blob/master/usage.txt

Mr. T
  • 51
  • 4
  • I can build my app too with --no-prune, but then it copies all the node_modules folder with also devDependencies and I don't want it. Without the --no-prune it should compile it just fine, why it is not? – Michael Denny Apr 04 '18 at 17:44
  • ok in my case I simply did this to make a cleaner package: `electron-packager . --no-prune --ignore=/node_modules --ignore=/e2e --ignore=/src` – Michael Denny Apr 04 '18 at 17:50
0

This is related to the issue #821in electron-packager with removing optional platform specific dependencies (possibly only when running packager on Windows).

--no-prune solves the problem during development, but won't work for production.

Reverting to v11.2.0 also solves the issue.

dgolovin
  • 1,412
  • 11
  • 23