Gagan
July 21, 2021, 3:31pm
1
I’m trying to use fs
module to store some data in json file. I used,
const fs=require('fs');
But i am getting following error,
Module not found: Error: Can't resolve 'fs' in '/home/ubuntu/Projects/hybrid/todo/src/js'
How can i remove this error?
fs
is a Node.js only thing. If you do a client app, you can’t use it
Gagan
July 22, 2021, 2:41pm
3
Is there any way to edit and save json in a file on client side?
If it is a web app then no. In Cordova app you can try to use this plugin GitHub - apache/cordova-plugin-file: Apache Cordova Plugin file
But if it is a single JSON and it is not huge, I would just store the data in localStorage
or on remote database
Gagan
July 23, 2021, 3:36pm
5
I will try cordova-plugin-file. I’m creating a hybrid todo app. I can’t decide whether to use sqlite database or store all data in json file. I will try both and see which one is fast.