2

I am working on steam project. For that I am using node-steam module. I am stuct at login part. I getting this exception while I am trying to logOn to steam account using node-steam Exception as follow:

Uncaught TypeError: undefined is not a function   MYAPP/node_modules/adm-zip/zipFile.js:8 
Module.exports  /MYAPP/node_modules/adm-zip/zipFile.js:8 
module.exports /MYAPP/node_modules/adm-zip/adm-zip.js:25
handlers.(anonymous function) /MYAPP/node_modules/steam/lib/steam_client.js:252 
SteamClient._netMsg`enter code here`Received /MYAPP/node_modules/steam/lib/steam_client.js:157
emitOne events.js:75
emit events.js:150
Connection._readPacket /MYAPP/node_modules/steam/lib/connection.js:50
emitNone events.js:65
EMIT events.js:147
emitReadable__  _stream_readable.js:408  
emitReadable   _stream_readable.js:402
readableAddChunk _stream_readable.js:157
Readable.push _stream_readable.js:109
onread net.js:510
Error: Disconnected
at SteamClient._disconnected (/MYAPP/node_modules/steam/lib/steam_client.js:186:24)
at emitOne (events.js:75:13)
at Connection.emit (events.js:150:7)
at TCP.close (net.js:457:12)

My source code is add follow:

var fs = require('fs');
var Steam = require('steam');
var crypto = require('crypto');

var serverlist = [] //server list here
Steam.servers = serverlist;

var steamClient = new Steam.SteamClient();
var steamUser = new Steam.SteamUser(steamClient);

steamClient.connect();

steamUser.on('updateMachineAuth', function (sentry, callback) {
    console.log('writing to file sentry');
    fs.writeFileSync('sentry', sentry.bytes);
    callback({ sha_file: getSHA1(sentry.bytes) });
});

function getSHA1(bytes) {
    var shasum = crypto.createHash('sha1');
    shasum.end(bytes);
    return shasum.read();
}

steamClient.on('connected', function () {    
    steamUser.logOn({
        account_name: “XXXXXXXX”,
        password: “XXXXXXXX”,
        // un-comment this when providing secondary auth-code from email
        auth_code: ‘XXX’,
        sha_sentryfile: getSHA1(fs.readFileSync('sentry'))
    });
});

steamUser.on('loggedOn', function () {
    console.log('Logged in!');
});


steamClient.on('debug', function (response) {
    console.log("debug: " + response);
});

steamClient.on('logOnResponse', function (response) {
    console.log(">>logOnResponse");
    console.log(response);

if (response.eresult == Steam.EResult.OK) {
    console.log('Logged in!');
    // Your code here
}

});

steamClient.on('error', function (error) {
    console.log(error.stack);
    alert("yes error");
});

steamClient.on('servers', function (servers) {
    alert(servers);
    // fs.writeFile('servers', JSON.stringify(servers));
});

steamClient.on('disconnected', function (s) {
    alert(s);
});

Below are my installed versions.

Node Version: v10.8.0 NPM Version: 6.4.1 Steam Version: 1.4.0 OS: Mac

Please help me to resolve this issue .

Priyanka
  • 31
  • 2

1 Answers1

0

The error that is being yield, undefined is not a function is happening because you are calling the function alert in node

That is not valid, as in node there is no function that is called like that, and since you have that function also in the errorHandler then the application dies.

If you were to delete the function alert of if you created and "alert" function that would console.log() what is happening the error should dissapear.

Try adding this function to your code or delete all of the alert functions:

const alert = () => {
  console.log(arguments)
}
Alejandro Vales
  • 2,816
  • 22
  • 41