TypeError:community.on不是函数

时间:2017-10-18 10:39:37

标签: node.js

我的节点-v是8.7(最新的) 这是代码行:

community.on('confKeyNeeded', function(tag, callback) {
    callback(null, time, SteamTotp.getConfirmationKey(account.identity_secret, time(), tag));
});

community.on('newConfirmation', function(confirmation) {
    var time = time();
    var key = SteamTotp.getConfirmationKey(account.identity_secret, time, 'allow');
    confirmation.respond(time, key, true, function(err) {
        if(err) {
            logger.error('Error on mobile auth');
            logger.debug(err);
            return;
        }
        logger.trace('Trade sucesfully confirmed');
    });
});

我在这里遇到这个错误:

  root@kokojambo13371:/var/bot# node bot_manager.js
        Database connection ID: 53
        List of bots:
        Launching bot# 1
        Bot with ID 1 started
        /var/bot/bot.js:228
        community.on('confKeyNeeded', function(tag, callback) {
                  ^

    TypeError: community.on is not a function
        at Object.<anonymous> (/var/bot/bot.js:228:11)
        at Module._compile (module.js:624:30)
        at Object.Module._extensions..js (module.js:635:10)
        at Module.load (module.js:545:32)
        at tryModuleLoad (module.js:508:12)
        at Function.Module._load (module.js:500:3)
        at Function.Module.runMain (module.js:665:10)
        at startup (bootstrap_node.js:187:16)
        at bootstrap_node.js:608:3
    Bot stopped with code 1
    /var/bot/bot.js:228
    community.on('confKeyNeeded', function(tag, callback) {
              ^

    TypeError: community.on is not a function
        at Object.<anonymous> (/var/bot/bot.js:228:11)
        at Module._compile (module.js:624:30)
        at Object.Module._extensions..js (module.js:635:10)
        at Module.load (module.js:545:32)
        at tryModuleLoad (module.js:508:12)
        at Function.Module._load (module.js:500:3)
        at Function.Module.runMain (module.js:665:10)
        at startup (bootstrap_node.js:187:16)
        at bootstrap_node.js:608:3
    Bot stopped with code 1`enter code here`
    ^Z
    [1]+  Stopped                 node bot_manager.js

使用托管firstvds,ubuntu 14.04,512mb

1 个答案:

答案 0 :(得分:0)

community.on('newConfirmation', function(confirmation) {
    var time = time();
    var key = SteamTotp.getConfirmationKey(account.identity_secret, time, 'allow');
    confirmation.respond(time, key, true, function(err) {
        if(err) {
            logger.error('Error on mobile auth');
            logger.debug(err);
            return;
        }
        logger.trace('Trade sucesfully confirmed');
    });
});

function query(sql, callback) {
    if (typeof callback === 'undefined') {
        callback = function() {};
    }
    pool.getConnection(function(err, connection) {
        if(err) return callback(err);
        logger.info('DB connection ID: '+connection.threadId);
        connection.query(sql, function(err, rows) {
            if(err) return callback(err);
            connection.release();
            return callback(null, rows);
        });
    });
}``