nodejs setMaxListeners to avoid memory leak detection

I read some other questions and posts, but I couldn’t find where to apply .setMaxListeners(0). I’m using a simple websocket-server which comes up with the errer: (node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit. Trace at Socket.EventEmitter.addListener (events.js:160:15) at Socket.Readable.on (_stream_readable.js:689:33) at XHRPolling.Transport.setHandlers (D:\nodeJS\host\node_modules\\lib\transport.js:116:15) at XHRPolling.HTTPPolling.setHandlers (D:\nodeJS\host\node_modules\\lib\transports\http-polling.js:53:39) at […]

How to insert html form element between label tag and text of label tag in jade

I need to generate following html markup in jade <div class=”checkbox”> <label> <input type=”checkbox”> Remember me </label> </div> My try:- .checkbox label Remember me input(type=”checkbox”) generates <div class=”checkbox”> <label> “Remember me ” <input type=”checkbox”> </label> </div> How can we place element “checkbox” infront of “Remember me” label text?

Multi-line commands in the sails console

Wrote multi-line command in the sails console but couldn’t execute them. Tried ending with semicolon ‘:’, pressing ctrl/alt/shift enter, but all they do is create new lines. How to execute multi-line commands in sails console? Just a simple example: User.find() .where({“name”:”John”}) .update({ “name” : “JohnGalt” }); Instead of all in the same line ..

Node.js – NPM pacakge publish locally and install the locally published NPM package for a Node.js application

I have created a local NPM pacakge, i am trying to install the local package using fallowing command “npm install ../replacevalue/replacevalue-0.1.1tgz”. This is giveing me fallowing error. My agenda is to “Locally test my npm modules without publishing them to”. 0 info it worked if it ends with ok 1 verbose cli [ ‘D:\\Program […]

how to define functions in redis \ lua?

I’m using Node.js, and the ‘redis-scripto’ module, and I’m trying to define a function in Lua: var redis = require(“redis”); var redisClient = redis.createClient(“6379″,””); var Scripto = require(‘redis-scripto’); var scriptManager = new Scripto(redisClient); var scripts = {‘add_script’:’function add(i,j) return (i+j) end add(i,j)’}; scriptManager.load(scripts);‘add_script’, [], [1,1], function(err, result){ console.log(err || result); }); so I’m getting […]

Can Express.js have a race condition on post

Node noob question here I’m sure. I have the below code in a simple express JS app var randomPin = require(‘./api/randomPin’); var currentPin = “pin”;‘/match’, function(req, res) { if ( && == currentPin) { //it should only be possible for one person to get here //and receive this hurrah currentPin = randomPin.generate(); res.send({hurrah:true}); […]

heroku — npm postinstall script to run grunt task depending on enviro

I’ve got two heroku node.js apps, one for prod and one for dev, and I also have a Gruntfile with dev- and prod-specific tasks. I know you can set up package.json to run grunt as a postinstall hook for npm, but can you specify somehow different tasks to be run depending on what enviro you’re […]

Use request module to retrieve JSON and return value

I use this request module to make HTTP request in Nodejs Sample code: module.exports.getToken = function(){ var token ; request(validLoginRequest, function(err,resp,body){ var json = JSON.parse(JSON.stringify(body)); console.log(“from request(): token=” + json.accesstoken); token = json.accesstoken; }); console.log(“getToken() returns:” + token); return token; } But the token is always undefined. What did I do wrong?

Convert Remote sparql endpoint json results into JSON-LD

I have a Sparql Endpoint(openrdf sesame) on my local machine. I am able to get the results of the queries(6) in json (using sparql-client node module). Now, I need to convert this json into json-ld so that I can easily display it in the jade file. How can I do this without using rdfstore-js in […]

Emulating ssh's ProxyCommand using the Node.js ssh2 module

I have a server (say, e.g., innerserver) that can only be reached from another server (say, outerserver), not the one running the Node server. However, the node server can reach outerserver. When using ssh from the command line I can use the ProxyCommand configuration file statement to simplify connections. My config file looks like this: […]

Node.js is the Best Javascript runtime in the world.