简体   繁体   English

在Meteor中访问node.js文件系统模块

[英]Access node.js File System module in 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. 我正在创建一个Web应用程序,它将编辑存储在用户HD上的一些配置文件,并决定给Meteor一个机会。

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. 我想使用Node.js的文件系统模块来处理配置文件的I / O,但我还没弄清楚如何包含该模块。 After some searching, I found the following code here on StackOverlow, which is supposed to allow me to require the module: 经过一番搜索,我在StackOverlow上找到了以下代码,这应该允许我需要模块:

var require = __meteor_bootstrap__.require;
var fs = require('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. 但是,即使将其放在我的代码的if(服务器)部分内部,我的应用程序仍然会抛出错误并告诉我'fs'未定义。

Has anyone else encountered this issue? 还有其他人遇到过这个问题吗?

从0.6.0你需要使用Npm.require

var fs = Npm.require('fs');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM