typicode / lowdb

Simple and fast JSON database
MIT License
21.49k stars 923 forks source link

Help wanted with fixing error after upgrading to v2 #486

Closed amsam0 closed 3 years ago

amsam0 commented 3 years ago

Hi everyone,

I recently updated lowdb to v2 and I've come across a weird error. I am using it in next.js.

error - ./node_modules/lowdb/lib/adapters/TextFile.js:1:0
Module not found: Can't resolve 'fs'
null

The weird thing about this is that it is running on the server side and it should be able to access fs.

Anyone know how to solve this?

Thanks in advance.

amsam0 commented 3 years ago

Just fixed it, sorry for making the useless issue

matepaiva commented 3 years ago

@naturecodevoid can you tell us how you fixed it? I got the same problem here. I am only using import { LowSync, LocalStorage } from "lowdb";.

amsam0 commented 3 years ago

It may not work on the client side with next.js, I'm not sure if its fixable. I was able to fix it by removing a sneaky import on the client side and adding dynamic imports for the server side but that probably won't work for you.

matepaiva commented 3 years ago

Right. I ended up not using lowdb. It was too difficult for using in a small project.

Thanks!