找不到所需模块的node.js变量

时间:2013-03-03 06:53:48

标签: javascript node.js

我试图弄清楚在我的代码中稍后尝试使用我的var fs = require('fs');变量时,我不知道javascript和/或节点是什么。我让它以相同的方式在另一个文件中工作,以及其他require d变量。代码如下......谢谢!

编辑:这是我得到的错误:ReferenceError: Can't find variable: fs

EDITEDIT:值得注意的是,我的fs = require('fs')文件中有world.js并且在此文件中也是必需的。

var keychain = require('keychain');
var world = require('./world').World;
var authentication = require('./authentication');
var fs = require('fs');

var getApps = function(appname, version, description){
  keychain.getPassword({ account: 'lightmanUsername', service: 'lightman' }, function(err,username) {
    keychain.getPassword({ account: 'lightmanPassword', service: 'lightman' }, function(err,password) {
      if (password === null) {
        console.log("Not logged in");
      } else {
        world(function(world) {

          authentication.authenticate(username,password);

          spooky.then(function(){
            this.capture('body.png', {
              top: 0,
              left: 0,
              width: 1080,
              height: 800
            });
          });

          spooky.then(function(){
            var app = this.evaluate(function(){
              return $('.fwb').text();
            });
            console.log("APPS: " + app);
            this.download('https://developers.facebook.com/apps', 'app_list.html');
          });

          spooky.then(function(){
            var appList = fs.readFile('app_list.html');
            console.log(appList);
          });

          spooky.run();

        });
      }
    });
  });
};
exports.getApps = getApps;

0 个答案:

没有答案