maximegris/angular-electron

The app cannot run in the browser

Epameinondas-Theodoropoulos opened this issue · 1 comments

Describe the bug
when i type npm run start or the command npm run ng:serve the follwing error appears:

./node_modules/electron/index.js:1:11-24 - Error: Module not found: Error: Can't resolve 'fs' in 'D:\Hard-Disk\Apps\Electron-Test\angular-electron-main\node_modules\electron'

If i run the app with npm run electron:local the app run correctly without problem. But only for native window, not for the browser

If i open 2 terminals and the first i run npm run electron:serve and in the other terminal run ng serve the app again run without problem. But only for native window, not for the browser. For the browser i have the following screenshot:
image
image

To Reproduce
Steps to reproduce the behavior:
I just downloaded the code.
i did the npm install
I run this command npm run start or the npm run ng:serve

Expected behavior
The expected behavior is to run both in the browser and in a window

Additional context
Angular CLI: 15.1.6
Node: 14.20.0
Package Manager: npm 6.14.17
OS: win32 x64

Angular: 15.1.5
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package Version

@angular-devkit/architect 0.1502.8
@angular-devkit/build-angular 15.1.6
@angular-devkit/core 15.2.8
@angular-devkit/schematics 15.1.6
@angular/cli 15.1.6
@schematics/angular 15.1.6
rxjs 7.8.0
typescript 4.8.4

"dependencies": { "@angular/animations": "15.1.5", "@angular/common": "15.1.5", "@angular/compiler": "15.1.5", "@angular/core": "15.1.5", "@angular/forms": "15.1.5", "@angular/language-service": "15.1.5", "@angular/platform-browser": "15.1.5", "@angular/platform-browser-dynamic": "15.1.5", "@angular/router": "15.1.5", "lodash": "^4.17.21", "primeflex": "^3.3.0", "primeicons": "^6.0.1", "primeng": "^15.3.0", "rxjs": "7.8.0", "tslib": "^2.5.0", "zone.js": "~0.12.0" },

Add any other context about the problem here.

Hi
Please check providers/electron.service.ts to watch how conditional import of libraries has to be done when using NodeJS / 3rd party libraries in renderer context (i.e. Angular).