在 Meteor 中访问 node.js 文件系统模块 [英] Access node.js File System module in Meteor
问题描述
我正在创建一个网络应用程序,该应用程序将编辑存储在用户 HD 上的一些配置文件,并决定尝试使用 Meteor.
I'm creating a web app that will edit some config files stored on a user's HD, and decided to give Meteor a shot.
我想使用 Node.js 的文件系统模块来处理配置文件的 I/O,但我一直无法弄清楚如何包含该模块.经过一番搜索,我在 StackOverlow 上找到了以下代码,它应该允许我需要该模块:
I'd like to use Node.js's File System module to handle to I/O of the config files, but I haven't been able to figure out how to include the module. After some searching, I found the following code here on StackOverlow, which is supposed to allow me to require the module:
var require = __meteor_bootstrap__.require;
var fs = require('fs');
然而,即使将它放在我代码的 if(server) 部分中,我的应用程序仍然会抛出错误并告诉我 'fs' 未定义.
However, even with this placed inside of the if(server) portion of my code, my application is still throwing an error and telling me that 'fs' is undefined.
有没有其他人遇到过这个问题?
Has anyone else encountered this issue?
推荐答案
从 0.6.0 开始你需要使用 Npm.require
From 0.6.0 you need to use Npm.require
var fs = Npm.require('fs');
这篇关于在 Meteor 中访问 node.js 文件系统模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!