Error running simple Electron program


#1

Hello, a few days ago I started to learn about electron and I started to make a small project to download youtube videos to test the things around. Here is the code

main.js:

const electron = require(‘electron’);
const path = require(‘path’);
const url = require(‘url’);
const youtubedl = require(‘youtube-dl’);

const {app, BrowserWindow, Menu, ipcMain} = electron;

let mainWindow;

app.on(‘ready’, function()
{
mainWindow = new BrowserWindow({});
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, ‘index.html’),
protocol: ‘file:’,
slashes:true
}));
mainWindow.on(‘closed’, function(){
app.quit();
});

const mainMenu = Menu.buildFromTemplate(mainMenuTemplate);
Menu.setApplicationMenu(mainMenu);
});

exports.getUrlInformation=(arg)=>
{
var url = arg;
var options = [];
youtubedl.getInfo(url, options, function(err, urlInformation)
{
if (err) throw err;

console.log('id:', urlInformation.id);
console.log('title:', urlInformation.title);
console.log('url:', urlInformation.url);
console.log('thumbnail:', urlInformation.thumbnail);
console.log('description:', urlInformation.description);
console.log('filename:', urlInformation._filename);
console.log('format id:', urlInformation.format_id);

mainWindow.webContents.send('UrlInformation', urlInformation);

});
}

index.js:

var {ipcRenderer, remote} = require(‘electron’);
var mainProcess = remote.require("./main.js");

class YouTubeDownloaderForm extends React.Component
{
constructor(props)
{
super(props);
this.state = {url: ‘’};
this.handleAddClick = this.handleAddClick.bind(this);
}
handleAddClick(event)
{
mainProcess.getUrlInformation(this.state.url);
}

I looked into devtool console and this is the error that shows up. Does this look like a installation error?

File not found (file:///c:/temp/Electron/YouTubeDownloader/node_modules/electron/dist/resources/electron.asar/browser/rpc-server.js


#2

Here is the full stack trace.

Uncaught Error: Could not call remote function ‘’. Check that the function signature is correct. Underlying error: spawn UNKNOWN
Error: Could not call remote function ‘’. Check that the function signature is correct. Underlying error: spawn UNKNOWN
at callFunction (~\node_modules\electron\dist\resources\electron.asar\browser\rpc-server.js:257:11)
at EventEmitter. (~\node_modules\electron\dist\resources\electron.asar\browser\rpc-server.js:357:5)
at emitMany (events.js:127:13)
at EventEmitter.emit (events.js:204:7)
at WebContents. (~\node_modules\electron\dist\resources\electron.asar\browser\api\web-contents.js:256:13)
at emitTwo (events.js:106:13)
at WebContents.emit (events.js:194:7)
at callFunction (~\node_modules\electron\dist\resources\electron.asar\browser\rpc-server.js:257:11)
at EventEmitter. (~\node_modules\electron\dist\resources\electron.asar\browser\rpc-server.js:357:5)
at emitMany (events.js:127:13)
at EventEmitter.emit (events.js:204:7)
at WebContents. (~\node_modules\electron\dist\resources\electron.asar\browser\api\web-contents.js:256:13)
at emitTwo (events.js:106:13)
at WebContents.emit (events.js:194:7)
at metaToValue (~\node_modules\electron\dist\resources\electron.asar\renderer\api\remote.js:234:13)
at Object.remoteMemberFunction (~\node_modules\electron\dist\resources\electron.asar\renderer\api\remote.js:118:18)
at YouTubeDownloaderForm.handleAddClick (:42:19)
at HTMLUnknownElement.callCallback (~/react-dom@16.2.0/umd/react-dom.development.js:580:14)
at Object.invokeGuardedCallbackDev (~/react-dom@16.2.0/umd/react-dom.development.js:619:16)
at Object.invokeGuardedCallback (~/react-dom@16.2.0/umd/react-dom.development.js:476:27)
at Object.invokeGuardedCallbackAndCatchFirstError (~/react-dom@16.2.0/umd/react-dom.development.js:490:43)
at executeDispatch (~/react-dom@16.2.0/umd/react-dom.development.js:972:19)
at executeDispatchesInOrder (~/react-dom@16.2.0/umd/react-dom.development.js:994:5)
at executeDispatchesAndRelease (~/react-dom@16.2.0/umd/react-dom.development.js:1092:5)


#3

When posting code, please remember to highlight it and press the </> button above the editor to mark that content as code in a way the forum understands. It’s very difficult to read code otherwise.


#4

Hello @DamnedScholar, heres’s the question, properly formatted.
A few days ago I started to learn about electron and I started to make a small project to download youtube videos to test the things around. Here is the code
main.js:

const electron = require(‘electron’);
const path = require(‘path’);
const url = require(‘url’);
const youtubedl = require(‘youtube-dl’);

const {app, BrowserWindow, Menu, ipcMain} = electron;

let mainWindow;

app.on(‘ready’, function()
{
mainWindow = new BrowserWindow({});
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, ‘index.html’),
protocol: ‘file:’,
slashes:true
}));
mainWindow.on(‘closed’, function(){
app.quit();
});

const mainMenu = Menu.buildFromTemplate(mainMenuTemplate);
Menu.setApplicationMenu(mainMenu);
});

exports.getUrlInformation=(arg)=>
{
var url = arg;
var options = [];
youtubedl.getInfo(url, options, function(err, urlInformation)
{
if (err) throw err;

console.log('id:', urlInformation.id);
console.log('title:', urlInformation.title);
console.log('url:', urlInformation.url);
console.log('thumbnail:', urlInformation.thumbnail);
console.log('description:', urlInformation.description);
console.log('filename:', urlInformation._filename);
console.log('format id:', urlInformation.format_id);

mainWindow.webContents.send('UrlInformation', urlInformation);
});
}

index.js:

var {ipcRenderer, remote} = require(‘electron’);
var mainProcess = remote.require("./main.js");

class YouTubeDownloaderForm extends React.Component
{
constructor(props)
{
super(props);
this.state = {url: ‘’};
this.handleAddClick = this.handleAddClick.bind(this);
}
handleAddClick(event)
{
mainProcess.getUrlInformation(this.state.url);
}

I looked into devtool console and this is the error that shows up. Does this look like a installation error?

File not found (file:///c:/temp/Electron/YouTubeDownloader/node_modules/electron/dist/resources/electron.asar/browser/rpc-server.js


#5

The code is similar to “Getting video information” from the url npmjs.com/package/youtube-dl. The code fails on the youtubedl.getInfo(url, options, function(err, urlInformation) line so i don’t think it is an issue with my code.

Here is the full stack trace.

Uncaught Error: Could not call remote function ‘’. Check that the function signature is correct. Underlying error: spawn UNKNOWN
Error: Could not call remote function ‘’. Check that the function signature is correct. Underlying error: spawn UNKNOWN
at callFunction (~\node_modules\electron\dist\resources\electron.asar\browser\rpc-server.js:257:11)
at EventEmitter. (~\node_modules\electron\dist\resources\electron.asar\browser\rpc-server.js:357:5)
at emitMany (events.js:127:13)
at EventEmitter.emit (events.js:204:7)
at WebContents. (~\node_modules\electron\dist\resources\electron.asar\browser\api\web-contents.js:256:13)
at emitTwo (events.js:106:13)
at WebContents.emit (events.js:194:7)
at callFunction (~\node_modules\electron\dist\resources\electron.asar\browser\rpc-server.js:257:11)
at EventEmitter. (~\node_modules\electron\dist\resources\electron.asar\browser\rpc-server.js:357:5)
at emitMany (events.js:127:13)
at EventEmitter.emit (events.js:204:7)
at WebContents. (~\node_modules\electron\dist\resources\electron.asar\browser\api\web-contents.js:256:13)
at emitTwo (events.js:106:13)
at WebContents.emit (events.js:194:7)
at metaToValue (~\node_modules\electron\dist\resources\electron.asar\renderer\api\remote.js:234:13)
at Object.remoteMemberFunction (~\node_modules\electron\dist\resources\electron.asar\renderer\api\remote.js:118:18)
at YouTubeDownloaderForm.handleAddClick (:42:19)
at HTMLUnknownElement.callCallback (~/react-dom@16.2.0/umd/react-dom.development.js:580:14)
at Object.invokeGuardedCallbackDev (~/react-dom@16.2.0/umd/react-dom.development.js:619:16)
at Object.invokeGuardedCallback (~/react-dom@16.2.0/umd/react-dom.development.js:476:27)
at Object.invokeGuardedCallbackAndCatchFirstError (~/react-dom@16.2.0/umd/react-dom.development.js:490:43)
at executeDispatch (~/react-dom@16.2.0/umd/react-dom.development.js:972:19)
at executeDispatchesInOrder (~/react-dom@16.2.0/umd/react-dom.development.js:994:5)
at executeDispatchesAndRelease (~/react-dom@16.2.0/umd/react-dom.development.js:1092:5)

#6

This seems to be an issue with npmjs.com/package/youtube-dl. I did not have an issue with https://github.com/fent/node-ytdl-core.