lowdb
lowdb copied to clipboard
Error [ERR_REQUIRE_ESM]: require() of ES Module from main.ts not supported.
I use Electron and in main.ts: import { JSONFile } from 'lowdb/node'; import { Low } from 'lowdb';
app
.whenReady()
.then(
() =>
new Low(
new JSONFile<{ dogs: any; cats: string[] }>(
${app.getPath('userData')}/db.json
,
),
{
coins: [],
accounts: {},
},
),
)
I get error: Error [ERR_REQUIRE_ESM]: require() of ES Module from main.ts not supported. Instead change the require of node.js in main.ts to a dynamic import() which is available in all CommonJS modules.