我使用的是FS包我的流星项目打开服务器启动的文件。 本地测试的时候,但是当我部署到服务器的流星,我收到此错误这工作完全正常。
WARNING Error: ENOENT, open '/server/filename.csv'
WARNING events.js:72
错误所在上来的代码:
Meteor.startup( function() {
var input = fs.createReadStream(process.env.PWD + 'server/filename.csv');
});
Meteor isn't designed for reading and writing files with fs
. When you bundle your Meteor app/publish it in production mode the folder structure is nothing like what it is in development.
You can read static files by creating a directory in your project called private
and placing your text files in it.
You can then read them (on the server side) as @David Weldon suggests:
var text = Assets.getText("filename.csv");
Keep in mind its not recommended to read files using fs
incase the production mode directory structure changes between Meteor versions.
Its not recommended to write files in case you have a different server serving the request which may not have the previously written file.