Reputation: 17636
Trying to import JSON file when server starts up.
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
var fs = Npm.require('fs');
Videos = fs.readFileSync("public/toc_vd_en.json", "utf8");
});
}
Getting a Error: ENOENT, no such file or directory 'public/toc_vd_en.json'
File structure:
I believe I'm giving the correct relative path. What is causing this error?
Upvotes: 0
Views: 2878
Reputation: 1213
mate, try this:
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
var base = process.env.PWD;
var fs = Npm.require('fs');
Videos = fs.readFileSync(base + "/public/toc_vd_en.json", "utf8");
});
}
Upvotes: 6