typicode / lowdb

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

Example from docs not working in react, PLEASE HELP... #542

Closed sahilrajput03 closed 2 years ago

sahilrajput03 commented 2 years ago

I used code from https://github.com/typicode/lowdb/tree/main/examples#browser Link to code: github.com/sahilrajput03/lowdb-not-working

Please help to assist in this issue.. , thanks in advance!

image

image

sahilrajput03 commented 2 years ago

I fixed this by adding some config for fs and path and now its working: https://github.com/sahilrajput03/lowdb-not-working/tree/fixed

npm i -D react-app-rewired path-browserify

You can see the diff of the commit here.

gianpaj commented 2 years ago

i have a similar issue.

"react-scripts": "3.4.0",
"lowdb": "^3.0.0",
import { LocalStorage, LowSync } from 'lowdb/lib';

const productsJSON = require('../data/products.json');

const adapter = new LocalStorage('db');

error

./node_modules/lowdb/lib/adapters/TextFile.js
Module not found: Can't resolve 'steno' in '.../node_modules/lowdb/lib/adapters'

Any ideas?