0

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

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

编辑编辑:可能值得注意的是,我的文件中确实拥有并使用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;
4

0 回答 0