[meteor 1.3] How to write json file like config.json?

[meteor 1.3] How to write json file like config.json ?
it tried with npm package but not work. has a problem with ‘fs’…
any solution ?

I always use http://jsonlint.com/ to validate any JSON I write. You don’t need a special package to write json files. Just a text editor.

oh no, i need save some options in json and user can change :smiley:
same as save in db just 1 record and publish + subscribe…
currently, i just done with read from json ( i using webpack )
write back to json has not yet @@

I see. I didn’t get that from the question. Might be that it was after 1 am my time when I read it.

1 Like

I highly doubt that’s the way you want to do something like this. What’s your use-case?

+1. I have the same problem
I want to store some configuration info a config.json, with both the possibilities to change it via UI or manually on the server (with default data for example).

But it seems quite impossible to use fs inside meteor 1.3
I tried
import * as fs from 'fs';
var fs = require('fs');
var fs = Npm.require('fs');

but nothing worked.
And I cannot find any package which could embed fs for me.

jsonfile seems to be a good candidate, but it cannot find fs as well.

I found a workaround using meteorhacks:npm
After installing, you can use it only on server side with a code like this:

const jsonFile = Meteor.npmRequire('jsonfile');
jsonFile.writeFile(filename, data, opts, fn);

I use jsonfile package, but you can use directly fs
const jsonFile = Meteor.npmRequire('fs');

Hope this helps you as well.