Skip to content
Advertisement

Why is my Angular 8 app not properly packaging my app using Electron Packager?

I have been trying to export my Angular 8 app to a desktop app using Electron. I figured out how to run it with Electron, but when I decide to use the electron packager I run into an error. The error I get has to do with the ‘app-root-path’ not being found. I am using a main.ts and turning it into the main.js Electron uses. Any help would be appreciated.

Main.ts

JavaScript

package.json

JavaScript

Whenever I compile the app and Electron-packager creates the exe I click it but I get the same error. “Javascript error: Error: Cannot find module ‘app-root-path’ require stack: /Invoices/Invoices electron app-darwin-x64/Invoices electron app.app/Contents/Resources/app/bin/main.js” The only other issue I had had was having to set the tsconfig.json target to “es5” and then I ran into this issue when trying to use Electron-packager.

Advertisement

Answer

What got this working for me was to first set the start electron command to this

JavaScript

then in my angular.json set OutputPath to

JavaScript

Then to fix my final error of “Failed to load module script:” I changed in my tsconfig.json

JavaScript

this fixed my application and allowed electron to work properly

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement