Jim
Jim

Reputation: 181

angular 5 with electron-packager

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?

Upvotes: 0

Views: 4678

Answers (4)

Jacob Nelson
Jacob Nelson

Reputation: 2476

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.

Upvotes: 1

dgolovin
dgolovin

Reputation: 1442

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.

Upvotes: 0

Michael Denny
Michael Denny

Reputation: 936

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

Upvotes: 7

Mr. T
Mr. T

Reputation: 49

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

Upvotes: 0

Related Questions