Latest Node.js Recipes

Node.js -- please help me with recursion

I have the following Node.js code:

var exec=require('child_process').exec;

var base_ctrl_port=8118;
var base_data_port=9050;
var nConns=10;

setInterval(watchdogCycle, 60000);   //check health every 60 seconds...


Read the entire recipe Recipe added 9 minutes ago

Process.nextTick or child_process?

I am trying to allow users to export their contact list in csv format. I am confused on how to run export_connect_csv() function. should i put it in child process or process.nextTick?

function export_connect_csv(user_id, file_location){

Read the entire recipe Recipe added 1 hour, 10 minutes ago

Node.js ssh won't run again

I have three Ubuntu servers, let's call them A, B, C. On server A, I have installed node.js and On server B, I have installed apache and php. I would like to send a event through php from server B to server A. When the event is...

Read the entire recipe Recipe added 2 hours, 10 minutes ago

Deploy Nodejs on Heroku fails serving static files located in subfolders

I'm deploying a NodeJs application using Heroku. Everything works fine except a little issue serving static files.

I have the following configuration

app.use(express.static(__dirname + '/htdocs'));

It works fine except when I try to serve static...

Read the entire recipe Recipe added 3 hours, 8 minutes ago

Socket.send on the server on page request

Is it possible for the server to do a socket.send on page request?

so it any client that request a certain page the server side can send a post message to all clients.

so when a web request comes into a page called "status". i want the server code...

Read the entire recipe Recipe added 4 hours, 7 minutes ago

Error calling 'npm install' with Meteor via Demeteorizer

I'm currently getting this error when trying to call 'npm install' on the generated file by demeteorizer.

npm WARN package.json gw2events@0.0.1 No repository field.
npm WARN package.json progress@0.0.5 No repository field.
npm WARN package.json...

Read the entire recipe Recipe added 5 hours, 12 minutes ago

How to integrate nodeJS + Socket.IO and PHP?

I have recently been looking around, to find a good way to communicate between nodeJS and PHP. Here is the idea : nodeJS is still quite new, and it can be kind of tricky to develop a full application only with it. Moreover, you may need it only for...

Read the entire recipe Recipe added 6 hours, 12 minutes ago

Attachment is not working properly in node-mailer?

Hi Am using node mailer to send mails.. It works fine with out attachment.But whenever i give some attachment it takes the default content 'data' as its content.. How should i avoid this..

My node mail function is looks like this...


Read the entire recipe Recipe added 7 hours, 9 minutes ago

NodeJS ExpressJS PassportJS - for Admin Pages Only

Im using NodeJS, ExpressJS, Mongoose, passportJS & connect-ensure-login. Authenticating users works perfectly.

var passport = require('passport')
  , LocalStrategy = require('passport-local').Strategy
  , ensureLoggedIn =...

Read the entire recipe Recipe added 8 hours, 9 minutes ago

module.exports in nodejs - fn vs object

I'm trying to understand the difference between the following two alternate representations of what I thought was the same functionality.


module.exports = function () {
    var apiRegistry = {};
    var files =...

Read the entire recipe Recipe added 9 hours, 10 minutes ago

What does ** mean in a path?

ive been setting up Grunt for my web app to auto build it and im seeing paths like


i understand what one wildcard means, but what does 2 in a row mean?

Read the entire recipe Recipe added 10 hours, 10 minutes ago

Which Node.js project uses a given dependency?

I have a folder that contains all my cloned GitHub repositories. Now I would like to get a list of all the repositories that reference a given dependency.

I think of something such as:

$ whouses async

And then I'd like to get a list of all...

Read the entire recipe Recipe added 11 hours, 8 minutes ago

Does asynchronous programming in node.js speed up CPU-bound tasks?

Earlier today I responded to a question with this answer. In the example that I posted, I used the synchronous version of a call in the bcrypt node module. I chose to use the synchronous version of the call primarily because I thought it made the...

Read the entire recipe Recipe added 12 hours, 12 minutes ago

How to change node.js swig module extension for .twig

My templates files extensions are .html and i cannot use autocompletion of my IDE which require .twig extension to do so

Read the entire recipe Recipe added 13 hours, 9 minutes ago

Apply function to field on all documents returned from MongoDB query in nodejs

I want to apply a truncate(string, words) function to the 'body' field of all Article documents returned by a mongoose query. An example would be as follows:

    .sort({'meta.created': 'desc'})

Read the entire recipe Recipe added 14 hours, 11 minutes ago

How to update npm package from a local folder

I cloned some npm package from github and put the package in a local folder, e.g.


I used "npm install -g" to install the package, which works really well.

npm install -g c:\git\package

However, when I did some change in the code...

Read the entire recipe Recipe added 15 hours, 5 minutes ago

Multiple Connections in node.js

I've been using node.js for a while and just playing around with the modules. I have a question, Is it possible to connect multiple node.js servers and have a communication link between them?

what I mean to say is, I have 3 node.js severs each...

Read the entire recipe Recipe added 16 hours, 8 minutes ago

SALT and HASH password in nodejs w/ crypto

I am trying to figure out how to salt and hash a password in nodejs using the crypto module. I am able to create the hashed password doing this:

UserSchema.pre('save', function(next) {
  var user = this;

  var salt =...

Read the entire recipe Recipe added 17 hours, 8 minutes ago

How to send data back to node from casperjs?

How can I send data back to node, from a process launched via execfile in nodeJS? preferably in a JSON format.

This is how my code looks like right now:

//index.js NodeJS
var execFile = require('child_process').execFile;
var express =...

Read the entire recipe Recipe added 18 hours, 12 minutes ago

Nodejs/Express - 'title' not rendering

I am working through Sams "Node.js in 24 Hours". Chapter 8 is giving me difficulty (longer more than an hour)! Example 07 allows the programmer to create a page whereby a user can create a task list that is stored in MongoDb. The code uses Express...

Read the entire recipe Recipe added 19 hours, 13 minutes ago

Easily print current package version in node.js

I have a node.js project to run on browser, so I have a Makefile with a few tasks that bundle everything in a single file (with browserify) and then minify it (uglify-js). I decided to use a Makefile instead of Grunt or others because it's simple and...

Read the entire recipe Recipe added 20 hours, 5 minutes ago

What is nodejitsu hosting details for nodejs

"A drone is an individual unit of computing power."

i cant understand what that means.... how much space?

incoming traffic per month?




internet speed?

I have searched their plans. They say you get 1drone for 10 dollars a...

Read the entire recipe Recipe added 21 hours, 12 minutes ago

Two database queries in Mongoose with Express

There are a lot instances where I have to make two database queries that depend on each other .. But because of the asynchronous nature of js, I can't set the order of these query requests. The work around I have been using is put one of the queries...

Read the entire recipe Recipe added 22 hours, 6 minutes ago

nodejs equivalent of this .htaccess

Is it possible to build a code like this in node.js?

<IfModule mod_rewrite.c>
     RewriteEngine on

     RewriteCond% {REQUEST_URI}! / (View) / [NC]
     RewriteCond% {REQUEST_FILENAME}!-F
     RewriteRule ^ (. *) $ Index.html [L,...

Read the entire recipe Recipe added 23 hours, 8 minutes ago

Store Series of 0s and 1s in MySQL database

I'm using MySql and Nodejs. I need to store a huge string made of only 0s and 1s. (This is a map grid. 0 = Can Move, 1 = Can't move.)


Read the entire recipe Recipe added 1 day ago