2

In an electron project, I want to acces a running chrome instance in order to open some sites, that I cannot open via command line (i.e. chrome://inspect). I tested the code on my machine locally and it works, when executed in the main-process of electron, but uploading an asar-file to a remote machine seems to cause the error named above. The error code states:

TypeError: (0, chrome-remote-interface_1.default[0]) is not a function

I tried to remove build optimaization, analyzed the resulting main.js, reinstalled the package multiple times and also tried to install other packages (i.e. devtools-protocol), which caused similar errors. I also tried the import-syntax, as well as the require-sytax (import CDP from "chrome-remote-interface" and const CDP = require("chrome-remote-interface")). It gets weird, when I upload the asar-file with the resources to the machine where it actually needs to be: Providing the code in the main-process causes instantly an error, while importing the code in the renderer-process even allows me to log the CDP-Object, which actually seems to carry the correct function-references (the comiled code is hard to read, but it is marked to be from the chrome-remote-interface module via comment). This seems to be odd, considering that this behaves different in my local machine.

This is the code in question:

const client = CDP();
const {Network, Page} = client;
await Network.enable();
await Page.enable();

await Page.navigate({url: 'chrome://inspect'});
await Page.loadEventFired();

While the const client = CDP() part is causing the error, it would also cause an error if I called CDP.List().

Update: I checked the main-file again and compared the available chrome-remote-interface-structure with other imported modules and noticed that some modules include files from within their lib-directory, which seem to be completly missing in the case of the chrome-remote-interface. I am currently trying to figure out if that might be causing issues on a remote machine. It seems unlikely as it works on my local machine. Any input on this matter would be appreciated.

udgey98
  • 21
  • 3

0 Answers0