Ajit Goel
Ajit Goel

Reputation: 4388

error running simple electron program

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;

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

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 (C:\temp\Electron\YouTubeDownloader\node_modules\electron\dist\resources\electron.asar\browser\rpc-server.js:257:11)
    at EventEmitter.<anonymous> (C:\temp\Electron\YouTubeDownloader\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.<anonymous> (C:\temp\Electron\YouTubeDownloader\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 (C:\temp\Electron\YouTubeDownloader\node_modules\electron\dist\resources\electron.asar\browser\rpc-server.js:257:11)
    at EventEmitter.<anonymous> (C:\temp\Electron\YouTubeDownloader\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.<anonymous> (C:\temp\Electron\YouTubeDownloader\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 (C:\temp\Electron\YouTubeDownloader\node_modules\electron\dist\resources\electron.asar\renderer\api\remote.js:234:13)
    at Object.remoteMemberFunction (C:\temp\Electron\YouTubeDownloader\node_modules\electron\dist\resources\electron.asar\renderer\api\remote.js:118:18)
    at YouTubeDownloaderForm.handleAddClick (<anonymous>:42:19)
    at HTMLUnknownElement.callCallback (https://unpkg.com/[email protected]/umd/react-dom.development.js:580:14)
    at Object.invokeGuardedCallbackDev (https://unpkg.com/[email protected]/umd/react-dom.development.js:619:16)
    at Object.invokeGuardedCallback (https://unpkg.com/[email protected]/umd/react-dom.development.js:476:27)
    at Object.invokeGuardedCallbackAndCatchFirstError (https://unpkg.com/[email protected]/umd/react-dom.development.js:490:43)
    at executeDispatch (https://unpkg.com/[email protected]/umd/react-dom.development.js:972:19)
    at executeDispatchesInOrder (https://unpkg.com/[email protected]/umd/react-dom.development.js:994:5)
    at executeDispatchesAndRelease (https://unpkg.com/[email protected]/umd/react-dom.development.js:1092:5)

Upvotes: 0

Views: 1320

Answers (1)

Ajit Goel
Ajit Goel

Reputation: 4388

I fixed the npmjs.com/package/youtube-dl issue by download the latest youtube-dl exe from https://youtube-dl.org/downloads/latest/youtube-dl.exe, then putting it in node_modules\youtube-dl\bin

Upvotes: 1

Related Questions