Error running a nodejs server on a Mac, 'no suitable image found'
NickName:David Da Silva Contín Ask DateTime:2012-07-30T17:37:25

Error running a nodejs server on a Mac, 'no suitable image found'

unknown406c8f2d5ecb:proves airrider3$ node tronServer.js
[Error: dlopen(/Users/airrider3/Documents/proves/node_modules/now/node_modules/node-proxy/build/Release/nodeproxy.node, 1): no suitable image found.  Did find:
    /Users/airrider3/Documents/proves/node_modules/now/node_modules/node-proxy/build/Release/nodeproxy.node: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00]
Error: dlopen(/Users/airrider3/Documents/proves/node_modules/now/node_modules/node-proxy/build/Release/nodeproxy.node, 1): no suitable image found.  Did find:
    /Users/airrider3/Documents/proves/node_modules/now/node_modules/node-proxy/build/Release/nodeproxy.node: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
    at Object.Module._extensions..node (module.js:485:11)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object.<anonymous> (/Users/airrider3/Documents/proves/node_modules/now/node_modules/node-proxy/lib/node-proxy.js:1:90)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)

It worked perfectly in Linux. I've just installed nodejs, nowjs, etc, runned this server script, but it keeps throwing this error.

Any ideas?

Server code: (it's kind of a tron multiplayer game)

var html = require('fs').readFileSync(__dirname + '/tronMultiplayer.html');
var server = require('http').createServer(function (req, res) {
   res.end(html);
});
server.listen(8004);

var nowjs = require('now');
var everyone = nowjs.initialize(server);

var bikes = {};
var killCount = {};
var player = 0;

var EMPTY = -1;
var WALL = -2;

var map = [];
var edge = 100;

var count = 0;
var deadbikes = 0;

var gameON = false;




function resetGame () {

    map = [];
    for (var i = 0; i < edge; i++){
        map.push([]);
        for (var j = 0; j < edge; j++){
            if (i == 0 || j == 0 || i == edge-1 || j == edge-1/* || Math.floor(Math.random()*30) == 0*/){
                map[i].push(WALL);
            } else {
                map[i].push(EMPTY);
            }
        }
    }   

    for (var i in bikes){
        spawnBike(i)
    }   
    everyone.now.reset(edge);
    everyone.now.updateScores(bikes);
}

nowjs.on('connect', function () {
   console.log('connect');
   bikes[this.user.clientId] = {nick: "Anonymous", w:0, i: Math.floor(Math.random()*edge-2)+1, j: Math.floor(Math.random()*edge-2)+1, di : 0, dj : 1, p: player, c: "rgba("+Math.floor(Math.random()*255)+ ", " + Math.floor(Math.random()*255)+","+Math.floor(Math.random()*255)+", 1)", alive : false};
   killCount[this.user.clientId] = 0;
   player++;
   console.log(this.user.clientId);
   console.log(bikes);
   if (!gameON){
    gameON = true;
    resetGame();
    step();
   }
});

everyone.now.changeBikeDirection = function (dir) {
    console.log(bikes[this.user.clientId].nick + " changes his direction to " + dir);
    var ndi = 0, ndj = 0;
    if (dir == "left"){
        ndj = -1;
    } else if (dir == "right"){
        ndj = 1;
    } else if (dir == "up"){
        ndi = -1;
    } else if (dir == "down"){
        ndi = 1;
    }
    var odi, odj;
    odi = bikes[this.user.clientId].di;
    odj = bikes[this.user.clientId].dj;

    if (odi != ndi && odj != ndj) {
        bikes[this.user.clientId].di = ndi; 
        bikes[this.user.clientId].dj = ndj;
    }
    killCount[this.user.clientId] = 0; 
};

everyone.now.updateNickname = function (theName) {
    bikes[this.user.clientId].nick = theName;
    everyone.now.updateScores(bikes);
};

function spawnBike (k) {
    bikes[k].i =  Math.floor(Math.random()*edge*(2/4) -2)+1 + edge/4;
    bikes[k].j = Math.floor(Math.random()*edge*(2/4)  -2)+1 + edge/4;
    bikes[k].di = 0;
    bikes[k].dj = 1;
    bikes[k].alive = true;
    player++;
}

nowjs.on('disconnect', function () {
   console.log(bikes[this.user.clientId].nick + ' has disconnected.');
   for (var i in bikes) {
      if (i === this.user.clientId) {
         killBike(i);
     delete bikes[i];
         break;
      }
   }
});

function killBike(k){
        var bike = bikes[k];
    bike.alive = false;
    for (var i = 0; i < edge; i++){
        for (var j = 0; j < edge; j++){
            if (map[i][j] == bike.player){
                map[i][j] = EMPTY;
            }
        }
    }
    //delete bikes[k];
}

function checkIfBikeIsDead(k){
        //console.log("CheckIfBikeIsDead with id "+k);
    var bike = bikes[k];
    if (bike.alive){
        //console.log("Checking current position");
        if (map[bike.i][bike.j] != EMPTY){
            //console.log("Ouch, Cell was "+map[bike.i][bike.j]);
            bike.i -= bike.di;
            bike.j -= bike.dj;
            killBike(k);

            for (var i in bikes){
                if (i != k){
                    if (bikes[i].alive){
                        bikes[i].w++;
                    }
                }
            }
            everyone.now.updateScores(bikes);           
            return true;
        } else {
            //console.log("Safe and sound");
            map[bike.i][bike.j] = bike.p;
            return false;
        }
    } else {
        return false;
    }

}

function traceMap() {
    console.log("---------------------------------------------------------------------");
    var s = "";
    for (var i = 0; i < edge; i++){
        s = "[";
        for (var j = 0; j < edge; j++){
            if (map[i][j] == undefined){
                console.log("We found an undefined at ("+i+","+j+")");
            } else {
                s += map[i][j].toString() + ", ";
            }
        }
        s += "]";
        console.log(s);
    }
}

function step () {

    count = 0;
    deadbikes = 0;

    for (var k in bikes){
        killCount[k]++;
        if (killCount[k] > 2000){
            killBike(k);
            delete bikes[k];
        } else {
            count++;
            if (bikes[k].alive){
                bikes[k].i += bikes[k].di;
                bikes[k].j += bikes[k].dj;
                if (checkIfBikeIsDead(k)){
                    deadbikes++;
                }
            } else {
                deadbikes++;
            }
        }
    }

    if (count > 0){
        if (count == deadbikes){
        resetGame();
        }
        setTimeout(step, 50);
        everyone.now.receiveNewPositions(bikes);
    //  traceMap();
    } else {
        gameON = false;
    }


}

Copyright Notice:Content Author:「David Da Silva Contín」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/11718813/error-running-a-nodejs-server-on-a-mac-no-suitable-image-found

Answers
David Da Silva Contín 2012-07-30T09:51:29

Nevermind. Facepalm. The node_modules folder I had was the same that I used/installed in Linux, so I believe that some parts were compiled specifically for Linux, or whatever.\n\nSolved by erasing the node_modules folder and reinstalling.\n\nI hope it helps to anyone with the same doubt!",


More about “Error running a nodejs server on a Mac, 'no suitable image found'” related questions

Control a mac with nodejs server

I do not really know where to post this question.. I have a nodejs server running on my mac. It listen for message if it receives "shutdown" then I run a command which turns off the mac. This works

Show Detail

keep nodejs server on azure VM running

I have a Windows Azure VM(linux server 14.04) running and am able to access the VM using command line on my mac/windows machines. I'm running a node.js server and a mongodb instance on this Azure V...

Show Detail

nodejs server - mac terminal crash every one hour

I got a live server running nodejs chat app. I connect to server using terminal on mac. I start the server by typing server.js. the problem is, my terminal always hung after one hour running, and...

Show Detail

Error in running my server using nodeJs express

While running my server using nodeJs express, I go below error: express-session deprecated undefined resave option; provide resave option server.js:16:9 express-session deprecated undefined

Show Detail

Running NodeJS in MAC OS 10.13

I'm using an old MAC OS and I didn't have any issue before, but after I reset it and installed the NodeJS and I tried the node -v or even npm -v I get this error message. adnanes-MacBook-Pro:react

Show Detail

CORS error for NODEJS server running on the same machine as domain

I have a NodeJS server running on my machine, and I am trying to access it with ajax from a website running on the same machine. I have getting a cross domain error though: XMLHttpRequest cannot load

Show Detail

ECONNREFUSED on running localhost server from NodeJS

I have a NodeJS server up and running on my local machine that is listening to port 50000. From another server, that is also running on my local machine, I need to make a simple GET request to that

Show Detail

Error when trying to connect to local MongoDB Server with nodeJS mongodb module

The error I am receiving: { [MongoNetworkError: failed to connect to server [127.0.0.1:37017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:37017]] name: 'MongoNetworkError...

Show Detail

Expected MAC different than incoming one from NodeJS to Go server

I'm having trouble trying to implement HMAC between my NodeJS and my Go servers. Right now, the expected MAC generated from my Go server is different than the actual MAC coming from my NodeJS serve...

Show Detail

NodeJS server error while running two servers

I have two NodeJS directories with same files except that the main one is running on PORT 8080 and other on PORT 9000. I am getting the following error while running the second service: TypeError [

Show Detail