Comments (3)
Fixed.
For future reference:
I found the code that was causing the problem:
Inside mmy source folder, somewhere in my angular app I was doing:
ipcRenderer.on('scanner-message', (event, message) => {
console.log('gotthemessage', message);
// Do something with the message, like updating the UI
});
Instead, what you're SUPPOSED to do; is import the provided electronService:
constructor(private electron: ElectronService) {}
and then use THAT thing's ipcRenderer, (it also has fs, and a few other things, i suppose the idea behind this service that wasn't clear to me at the start was that this is a helper service that allows 'safe' access to nodeJs things, without blowing up when running on the browser that doesn't have access to nodeJS).
this.electron.ipcRenderer.on('scanner-message', (event, message) => {
console.log('gotthemessage', message);
// Do something with the message, like updating the UI
});
I understand now.
Thank you for the project; Very nice.
from angular-electron.
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).
from angular-electron.
./node_modules/electron/index.js:1:11-24 - Error: Module not found: Error: Can't resolve 'fs' i
Why is the error appearing inside of index.js in node_modules?
the 'fs' of getElectronPath:
const fs = require('fs');
const path = require('path');
const pathFile = path.join(__dirname, 'path.txt');
function getElectronPath () {
let executablePath;
if (fs.existsSync(pathFile)) {
executablePath = fs.readFileSync(pathFile, 'utf-8');
}
if (process.env.ELECTRON_OVERRIDE_DIST_PATH) {
return path.join(process.env.ELECTRON_OVERRIDE_DIST_PATH, executablePath || 'electron');
}
if (executablePath) {
return path.join(__dirname, 'dist', executablePath);
} else {
throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again');
}
}
module.exports = getElectronPath();
I can't see where my application code is importing fs, how can I find it?
The readme says:
NodeJS's one - Uses NodeJS core module (crypto, fs, util...)
I suggest you add this kind of 3rd party library in dependencies of both app/package.json and package.json (root folder) in order to make it work in both Electron's Main process (app folder) and Electron's Renderer process (src folder).
But you can't actually add 'fs' or any of those core modules into package.json.
One possibility is i'm important and using a module that itself is importing fs somewhere inside it; but i can't figure out which one.
from angular-electron.
Related Issues (20)
- Unable to run ngx-monaco-editor with electron HOT 1
- Any way to update form angular-electron 13 to 16 HOT 1
- Cannot install angular material HOT 2
- A JavaScript error occurred in the main process HOT 1
- Open link start with "#" on Angular HOT 1
- New window HOT 1
- Karma is now deprecated, what's next? HOT 2
- Firebase Not working in desktop app while it's working in (Web Serve & Build) HOT 2
- How to setup findInPage?
- Loading preload scripts HOT 1
- Notification Mini Icon on window
- Kinectron HOT 2
- Electron Builder for windows: Icon Paths Not Translated with Macro in Output Directory HOT 1
- How can I change the splash screen image? HOT 4
- What about esbuild? HOT 3
- [Bug]: failed: Error in connection establishment: net::ERR_CERT_AUTHORITY_INVALID when connect mqtt with ca certificate
- What about Nrwl NX? HOT 2
- [Bug]: Application gives blank white screen when tried to reload HOT 2
- Add DesktopCapturer to ElectronService HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-electron.