#597·lowdb

lowdb doesn't create database

Author: uniboxxCreated Sep 18, 2024Updated Aug 13, 2025

Hi, here my code:

import { JSONFilePreset } from 'lowdb/node';

const defaultData = { posts: [] }; const db = await JSONFilePreset('db.json', defaultData);

If I run the server with this code the db.json doesn't be created. It will if I add this line.

db.write();

As I see in the instructions it should work without the last line. Any suggestion?