i confused, need use fs package meteor.js fw.
from meteor version 0.6> need use npm.require this:
var fs = npm.require('fs');
but when error appear: npm not defined
how solve it? tried mrt add npm hm...
btw: have /root/packages/npm
edit code in both client/server side folder moved block server
var fs; if(meteor.isserver) { fs = meteor.require('fs'); } fs.writefile(path + name,... getting error: cannot call method writefile of undefined
solved solved error wraping whole content meteor.isserver {... if someoen explain me curiosity why not work above?
you need add package.js
in app or smart package explicitly specifies dependency via npm.depends
before can use npm.require
. don't need npm.depends
or smart package if using built-in npm
package such fs
, still need make sure using on server-side , not client side.
for example, check out package.js
file meteor package pulls in sharejs: https://github.com/mizzao/meteor-sharejs/blob/master/sharejs-ace/package.js
see post: http://shiggyenterprises.wordpress.com/2013/05/16/accessing-the-file-system-in-meteor/
Comments
Post a Comment