lehtu
lehtu

Reputation: 907

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..

Upvotes: 3

Views: 10296

Answers (1)

David Weldon
David Weldon

Reputation: 64342

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

var fs = Npm.require('fs');
var data = fs.readFileSync(filepathHidden);

Upvotes: 7

Related Questions