Open chunten opened 9 months ago
I'm having the same issue
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
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)