nodejs is throwing symbol lookup error - node.js

This is the first time I am getting this error using nodejs, not sure what is it and how to come out of it. Below is the error:
node: symbol lookup error: /home/zishan/node_modules/zmq/build/Release/zmq.node: undefined symbol: zmq_sendmsg
when I am getting above error:
I have two test scripts testServer.js and testClient.js, when I am running testServer.js it's working fine but when I am running testClient.js by node testClient.js than testServer.js node window immediately throws above error.
below is the code for both scripts.
// testServer.js
var zmq = require('zmq');
var socket = zmq.socket('push');
socket.bindSync('tcp://127.0.0.1:3000');
console.log('Server is open on port 3000');
setInterval(function(){
console.log('sending work');
socket.send('some work');
}, 500);
Below is testClient.js
var zmq = require('zmq')
var socket = zmq.socket('pull');
socket.connect('tcp://127.0.0.1:3000');
console.log('client connected to port 3000');
socket.on('message', function(msg){
console.log(msg.toString());
});
My Env.
Ubuntu - 13.04
Nodejs - 0.10.24
Recently i reinstalled node using How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X) because i got hit by this error node-gyp rebuild.
Any help is much appreciated.

Can you try uninstalling latest zmq module by npm uninstall zmq and try with specific version of zmq npm install zmq#2.4.0

Related

How to run node on server

i am new in node.js and i want to create chat system so anybody help me that how can i run my codes on local and on server
Server - (app.js):
var io = require('socket.io')(80);
io.on('connection', function (socket) {
socket.on('message', function () { });
socket.on('disconnect', function () { });
});
Client - (index.html):
<script>
var socket = io('http://localhost/');
socket.on('connect', function () {
socket.send('hi');
socket.on('message', function (msg) {
// my msg
});
});
</script>
what is server (app.js) and how can i run this on my server and how can i call this function to client ?
Step 1. Install node.
Download package from https://nodejs.org/en/, then you got npm and node file.
Create soft link to /usr/local/ for npm and node file.
Step 2. Crate your app.js, and typing:
node app.js
then, your code is running. And you can test in your frontend.
If you wanna your code running background, you can use pm2.
npm install -g pm2
After that, pm2 start app.js. Your code is running background.
See https://www.tutorialspoint.com/socket.io/socket.io_hello_world.htm
You need node installed on your server as a prerequisite.
Once you have nodejs installed, the app can be executed as node app.js

resolve the error module.js:339

This is my server.js code and I want a solution on how to resolve the error: can't find the module 'connect'
var connect = require('connect');
var port = 3000;
connect.createServer connect.static(__dirname )
).listen(port);
console.log('Connect via port '+port);
You need to install the package connect. Use the npm install command to install the connect package.
npm install connect

Node JS Net.Connect ECONNREFUSED

I created a very simple Node.JS script which is suppose to connect to a server on port 3200. The code works great on Windows 8.1 x64, but when I moved it to a Ubuntu Server machine I am getting a ECONNREFUSED.
I tried to connect via IP Address and the Domain Name, but neither work. It always gives me ECONNREFUSED.
When I SSH into the Ubuntu Server I can do a telnet to the server/port and it works fine. Also pinging the server works. Just Node.JS doesnt connect.
Server:
Ubuntu Server 12.04.3 LTS (precise)
Here is the code:
var net = require('net');
var socket = net.connect({port: 3200, host: '172.19.16.203'}, function() {
// Connection Successful
console.log('Socket connected...');
// Data Received from Server
socket.on('data', function(d) {
console.log('data');
});
socket.on('end', function() {
});
socket.on('error', function(e) {
});
});
I found the solution. I was running my script by the following command:
node test.js
I guess the node is an old version. I upgraded the OS to the latest version and then did:
apt-get install nodejs
I run the script like following:
nodejs test.js
And it works!

Redis in Nodejs on Cloud9 IDE: [Error: Auth error: undefined]

Here is my code:
var express = require("express"),
app = express(),
server = require("http").createServer(app),
io = require("socket.io").listen(server),
redis = require("redis"),
env = {PORT: process.env.PORT || 8080, IP: process.env.IP || "localhost"};
client = redis.createClient(env.PORT , env.IP);
client.on("error", function(err) {
console.log(err);
});
server.listen(env.PORT);
console.log("Server started # " + env.IP + ":" + env.PORT);
After trying to run, I received the followings on the console:
Running Node Process
Your code is running at 'http://modified.address.c9.io'.
Important: use 'process.env.PORT' as the port and 'process.env.IP' as the host in your scripts!
info: socket.io started
Server started # modified.ip.address.1:8080
[Error: Auth error: undefined]
I tried establishing the connection, and it connects to the IP and PORT perfectly. However, the error [Error: Auth error: undefined] appears and stops there. I Googled the error, the supports from the IDE I used..., and surprisingly, there are only 7 links to my problems. So I think it may be a hole in my knowledge or it is not really a problem yet a thing I don't know to work it out. All I could pull out from those Google results were (I was not sure) I need to use client.auth(pass) right after creating it. But where should I find the password? When I installed it npm install redis I didn't configure anything and wasn't told to set password whatsoever. So I reach the impasse.
I use Cloud9 IDE (c9.io), and the modules used as shown in the code above.
----With best regards,
----Tim.
I've found out what was wrong.
I did install Redis, but that is a Redis library that acts like a bridge between Redis driver and NodeJS. On Cloud9, I have to manually install Redis, too.
So it would take 2 commands to actually install Redis:
Install the Redis Driver on Cloud9
nada-nix install redis
Install Redis library for NodeJS
npm install redis
Thanks for anyone who was trying to help me.
You can run the redis-server using your own config file.You can create your own config like below.
//port and ip of ur redis server
port 6371
bind 127.0.0.1
//password for this server
requirepass ucanmentionurpwd
//storing snapshots of the data
save 60 1
dbfilename dump.rdb
dir /tmp/db
//starting redis server
redis-server //ur config file location
See this link for redis configuration
https://raw.github.com/antirez/redis/2.6/redis.conf
If you mention requirepass with your password means only you need to do
client.auth('urPwd');
Otherwise no need to call the client.auth method.

Cannot find module 'connect' on Mac OS X Lion

I installed connect module using NPM running the following command:
npm install connect
it created the module in /Download/usr/node_modules/connect folder. I created a file which
uses connect module using
var connect = require('connect');
var util = require('util');
function sendjson(res,obj)
{
res.writeHead(200,{'Content-Type':'application/json',});
var objstr = JSON.stringify(obj);
util.debug('SENDJSON' + objstr);
res.end(objstr);
}
var server = connect.createServer(
connect.router(function(app){
app.get('/foo', function(req,res){
sendjson(res,{path:'foo'});
})
app.get('/bar', function(req,res){
sendjson(res,{path:'bar'});
})
})
);
server.listen(3000);
I run node createServer.js and it throws in the terminal and it gives me the following error.
Cannot find module 'connect'
NPM modules by default need to be installed locally in the folder that contains the source file that uses them. So if your source file is in /Desktop/nodescripts, you should run "npm install connect" in that same folder. That will create node_modules folder in that path, and your script will be able to find it.

Resources