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

Electron-dl returns undefined no matter what I do... #119

Closed
LoganTann opened this issue Aug 25, 2020 · 1 comment
Closed

Electron-dl returns undefined no matter what I do... #119

LoganTann opened this issue Aug 25, 2020 · 1 comment

Comments

@LoganTann
Copy link

LoganTann commented Aug 25, 2020

Hello,
I installed this package and it doesn't work in my PC... Making a request will always return undefined.
Tried to restart my computer, download a sample page, disabling every security stuff I made, nothing makes it work...

Dependencies : electron: ^9.2.1, electron-dl: ^3.0.2
OS : Windows 10

sample code :

const electronDl = require('electron-dl');
function createWindow () {
  // Create the browser window.
  const mainWindow = new BrowserWindow({
    width: 1280,
    height: 720,
    minWidth: 300,
    minHeight: 600,
    icon: "favicon.ico",
    webPreferences: {
        nodeIntegration: true,
        contextIsolation: false, // 
        enableRemoteModule: true, // 
        preload: path.join(__dirname, 'preload.js')
    }
  })

  console.log(electronDl);
  electronDl(mainWindow, "https://google.fr/").then(
    r => console.log(r)
  );
  // ....
}

console output :

Logan@MSI ~/Documents/kagepro3_launcher (master)$ npm run start

> kagepro3_launcher@0.1.0 start C:\Users\Logan\Documents\kagepro3_launcher
> electron .

[Function] { download: [Function] }
(node:14028) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'then' of undefined
    at createWindow (C:\Users\Logan\Documents\kagepro3_launcher\main.js:45:69)
    at C:\Users\Logan\Documents\kagepro3_launcher\main.js:189:3
[....]

@LoganTann
Copy link
Author

I solved the problem, by editing const electronDl = require('electron-dl'); to const {download} = require('electron-dl');

It's because electron-dl exports the download function as a part of an object ... Wow, hours spends for that beginner mistake 🤦 ...
https://stackoverflow.com/a/49828577

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

1 participant