Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipcRenderer can't resolve 'fs' or 'path' #204

Closed
JavaNocKziK opened this issue Jul 1, 2018 · 3 comments
Closed

ipcRenderer can't resolve 'fs' or 'path' #204

JavaNocKziK opened this issue Jul 1, 2018 · 3 comments

Comments

@JavaNocKziK
Copy link

When checking out 4.0.0 or 4.1.0 I can't use the ipcRenderer in an Angular component, when I do it errors with:

ERROR in ./node_modules/electron/index.js
Module not found: Error: Can't resolve 'fs' in 'C:\...\node_modules\electron'
ERROR in ./node_modules/electron/index.js
Module not found: Error: Can't resolve 'path' in 'C:\...\node_modules\electron'

Here is the code from the component, it's just the stock 'home' one:

import { Component, OnInit } from '@angular/core';
import { ipcRenderer } from 'electron';

@Component({
    selector: 'app-home',
    templateUrl: './home.component.html',
    styleUrls: ['./home.component.scss']
})
export class HomeComponent implements OnInit {
    constructor() {}
    ngOnInit() {}
    public action() {
        ipcRenderer.send('test', 'message');
    }
}

If I comment out the send in the action method then it runs just fine, so the import isn't the problem.

@JavaNocKziK
Copy link
Author

When using 3.4.1 of angular-electron it works, but only when using:

const electron = window.require('electron');

If I use:

import { ipcRenderer } from 'electron';
// or
import * as electron from 'electron'

Then I get something like r.existssync is not a function from the Chrome console.

I'm manually upping the packages from 3.4.1 to see what happens.

@JavaNocKziK
Copy link
Author

Just tried the above in 4.1.0 and that also works. So I guess I'll just keep using the window.require? I have an older project that could just use a normal import. Not sure what's changed.

@maximegris
Copy link
Owner

Hi,

Please have a look at electron.service.ts to see how to import & use nodeJs/Electron modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants