import { JSONFilePreset } from 'lowdb/node'
type Data = {
messages: string[]
}
const defaultData: Data = { messages: [] }
const db = await JSONFilePreset<Data>('db.json', defaultData)
db.data.messages.push('foo')
The error:
lowdb_node.js?v=0050ebbd:74 Uncaught TypeError: (0 , import_node_path.dirname) is not a function
at getTempFilename (lowdb_node.js?v=0050ebbd:74:66)
at new Writer (lowdb_node.js?v=0050ebbd:104:39)
at new TextFile (lowdb_node.js?v=0050ebbd:162:33)
at new DataFile (lowdb_node.js?v=0050ebbd:218:34)
at new JSONFile (lowdb_node.js?v=0050ebbd:266:5)
at JSONFilePreset (lowdb_node.js?v=0050ebbd:335:42)
at App.tsx:12:18
Maybe it's only available on the server side?
Also, this warning comes as well:
My stack: Vite + React + TS
The small TypeScript example is not working:
The error:
Maybe it's only available on the server side? Also, this warning comes as well: