BetaHuhn / electron-win-state

🖼️ :electron: Store and restore your Electron Window's Size and Position.
https://readme.fish/BetaHuhn/electron-win-state
MIT License
13 stars 2 forks source link

TypeError: WinState is not a constructor #396

Open chunten opened 10 months ago

chunten commented 10 months ago

import WinState from 'electron-win-state' const winState=new WinState({})

TypeError: WinState is not a constructor at Object. (F:\electron\electron-app\out\main\index.js:7:18)

ty-zyp commented 8 months ago

I'm having the same issue

linuswillner commented 6 months ago

Here's what I found out:

import WinState from 'electron-win-state'
console.log(WinState)
// ✅ expected: class WinState
// ❌ actual: { default: class WinState }

What's strange is that it worked just fine after I first installed the module, but the next time I tried to start my application, it stopped working. Could this be some sort of weird ESM/CJS issue?

In any case, here's how to wrangle it back into shape (it's a little awkward, but it works):

import ElectronWinState from 'electron-win-state'
const WinState = (ElectronWinState as unknown as { default: typeof ElectronWinState }).default
console.log(WinState) // ✅ class WinState