Skip to content

Can't resolve 'child_process' with electron app + Angular + TS #218

@metal3d

Description

@metal3d

Hi,

I'm trying to create an application that embed Angular in Electron.

My package.json file includes "@kubernetes/client-node": "^0.8.1" and "electron": "^4.0.8",

I'm building a service that prepare the client:

import { Injectable } from '@angular/core';
import { Core_v1Api, KubeConfig } from '@kubernetes/client-node';

@Injectable({
  providedIn: 'root'
})
export class K8sService {
  public k8sApi;

  constructor() { 
      const kc = new KubeConfig();
      kc.loadFromDefault()
      this.k8sApi = kc.makeApiClient(Core_v1Api);
  }
}

Then I try to build the application:

ng build --prod

The given error is:


ERROR in ./node_modules/shelljs/src/exec-child.js
Module not found: Error: Can't resolve 'child_process' in '/home/pafer/Projects/mainsail/node_modules/shelljs/src'
ERROR in ./node_modules/shelljs/src/exec.js
Module not found: Error: Can't resolve 'child_process' in '/home/pafer/Projects/mainsail/node_modules/shelljs/src'
ERROR in ./node_modules/aws-sign2/index.js
Module not found: Error: Can't resolve 'crypto' in '/home/pafer/Projects/mainsail/node_modules/aws-sign2'
ERROR in ./node_modules/aws4/aws4.js
Module not found: Error: Can't resolve 'crypto' in '/home/pafer/Projects/mainsail/node_modules/aws4'
ERROR in ./node_modules/ecc-jsbn/index.js
Module not found: Error: Can't resolve 'crypto' in '/home/pafer/Projects/mainsail/node_modules/ecc-jsbn'
ERROR in ./node_modules/http-signature/lib/signer.js
Module not found: Error: Can't resolve 'crypto' in '/home/pafer/Projects/mainsail/node_modules/http-signature/lib'
ERROR in ./node_modules/http-signature/lib/verify.js
...
...

There is no webpack configuration (and I have to say that I really don't know how and why some issues says to use one).

Without Angular, using only TS, it seems to work (I can list namespaces for example).

Is there anything to do to make it working with Angular ?

Keep in mind that I'm using Angular inside Electron app, not through a real web browser.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions