Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meteor: "ReferenceError: fs is not defined"

Losing my mind with this one..

Getting "fs is not defined" on meteor when trying to read a file:

var data = fs.readFileSync(filepathHidden);

I have this package: cfs:filesystem 0.1.2 on Meteor 1.1.0.2

Funny thing here is that if I write in meteor shell fs it prints object and it seems to have lot of functions etc stuff. But the thing here is that after writing fs in meteor shell my code starts to work!? And if I close meteor server and then start it again my server code keeps nagging until I run fs in meteor shell...

Can someone please explain what happens in this case? And how to achieve same thing in my code..

like image 803
lehtu Avatar asked Dec 01 '25 06:12

lehtu


1 Answers

You just need to load it in via npm. In meteor that looks like:

var fs = Npm.require('fs');
var data = fs.readFileSync(filepathHidden);
like image 138
David Weldon Avatar answered Dec 03 '25 19:12

David Weldon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!