Latest Node.js Recipes

Combine multiple node.js web applications

I'm trying to figure out the best way to accomplish this; essentially I have about 6 websites I have to get online but at the moment they will have next to zero traffic so to save money they need to be deployed on the same server (ideally we will be...

Read the entire recipe Recipe added 6 minutes ago

Specify host parameter for Node.js on Amazon EC2

Most of my node apps I have been able to start like this:


Now I am working with a phantomJS script which requires you to pass the host and port when starting the server. I have not been able to even get a simple hello world to...

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

Separating RESTful services from main web site architecture using Node.js

I'm starting a new project and I'd like opinions on my idea for a server architecture. Here's the setup:

  1. There is a client app on many devices (phones, tablets). These all need to make RESTful connections to a server for data. This server already...

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

Node / Express Directory Browsing

Im trying all day long to solve this problem:

I have an directory with subdirectories, f.e.:

 | Music Artist 1
 | - Album Nr 1
 | -- Track 1
 | -- Track 2
 | -- ...
 | - Album Nr 2
 | -- Track 1
 | -- Track 2
 | -- ...
 | Music Artist 2
 | - Album...

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

nodejs throw er; // Unhandled 'error' event

I made following, to play a bit around with node.js. The files in the folder zipfiles are zipped accordingly and everything seems to work. But I got an error on the cmd and I don't know where it comes from or how to solve it.


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

Caching mongoose objects with Redis

Is it possible to cache, say, mongoose document obejcts in Redis, perhaps for implementing a write-back or write-through cache with timeout-based cache flush mechanisms?

P.S.: I am familiar with mongoose-redis-cache, but I guess it supports only lean...

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

render a full web page in node.js code

I am running a node.js server, and it is rendering a web page wonderfully. When I look at this in a browser, it runs exactly as I expect.

However, what I actually want to do is make the call to fully generate the html page - exactly as it is in the...

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

Simple Express program for querying a result

I have a snippet of Express code

Below what i am trying to do is pass the table name to keyName by extracting from the request

But I am facing deaslock

i wanted to know whether i am following proper protocols for JSON...

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

NodeJS, Windows, wmic stdin

I've having a problem with the Windows program WMIC.exe (used for querying Windows Management Instrumentation), from within NodeJS.

I can spawn a wmic.exe process, but it'll not output anything or accept any input. However, if I set the stdin to...

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

Express cookieSession and Mongoose: how can I make request.session.user be a Mongoose model?

When a new user account is created, I create newUser, a Mongoose model instance that looks like:

_events: Object
errors: undefined
isNew: false
save: function () {
arguments: null
caller: null
_doc: Object
  name: 'Joe Smith'

The actual data...

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

Is there a way to have node preserve command line history between sessions?

When I run node from the command line with no arguments, I enter an interactive shell. If I execute some commands, exit node, and restart node, the up arrow doesn't do anything (I'd like it scroll through my previous commands).

Is there a way I can...

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

Downloading Steroids.js using Node.js

I'm currently looking to download Appgyver's Steroids.js but keep running into the following problem:

enter image description here

I'm not entirely sure what the problem is as I'm not very experienced with using Node.js as I doubt this problem is made by Appgyver's...

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

Usage of and express js

I am new to Node js and just now I come across through and express js, I want to know the difference between them or the relation between them. I am having some small codes that was used for the chat application

In the nodeClient.js


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

How to compare two images using Node.js

I am looking for a way to compare two images to see how similar they are. Googling it produces tons of image processing results (cropping, re-sizing, etc.), but nothing that would do approximate comparisons of images. There is one Node.js library, but...

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

Advantages of XOAUTH2 in nodemailer

The nodemailer module (allows to send emails in a node.js app) supports XOAUTH2 authentication against Gmail accounts. Why would one want to use this for general purpose email notifications as opposed to just specifying the user: and pass: parameters...

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

Q.js: How can I rewrite an async series flow in Q.js?

In an attempt to grasp Q.js, I'd like to convert the following code using async.series in Q.js. Basically I create a folder if it doesn't exist (using mkdirp), move a file into a backup folder and save a file into a main folder.

var async =...

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

NodeJs and ExpressJs Cannot Set Cookie

Can you help me for creating cookies cause i can't make it work. I would like to set and create cookies after the user logs in but I don't know what's wrong with my codes. Thanks Guys.

Here's my code, if you think there's other error's or code...

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

Can multiple meteor application server instances work behind Hipache reverse proxy?

I want to load balance my Meteor application using Hipache reverse proxy. Single application server instance works well, but when I add the second one, I get the following error in browser:

WebSocket connection to...

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

Express server receiving POST Request

Below is a Express program

PROBLEM:: I am not getting a proper JSON RESPONSE in CLIENT


  • Whether I have written proper code in server(Express) when i give a post request from the client
  • The client sends request in the form of...

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

How to access client IP address in Meteor?

This seems like a very basic question that doesn't have an elegant solution/answer out there.

How can I access the client (remote) IP address from (1) the server or (2) the client?

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

sequelizejs saving an object when row was removed

I have the following code. The idea is that I update a database row in an interval, however if I remove the row manually from the database while this script runs, the save() still goes into success(), but the row is not actually put back into the...

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

How to use 'this' context in middleware

I wrote my own middleware as module for my purposes that looks like the following:

-- myMiddleware.js

module.exports = {
    fn1: function (req, res, next) {

    fn2: function (req, res, next) {

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

Sails.js: Specifying query column as a variable in where clause when querying model

I would like to dynamically specify a query column in a where clause while querying a model, is this possible? I have tried several different ways with no luck. If I run something like this I get Logic db error because it is looking for a column...

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

How to connect a user to sockets

I am trying to connect the user session id created with the cookie created for each user after login along with connecting it to the sockets... any direction or examples will be great... I am using nodejs, express, redis, and using mongodb...

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

How to set tarball url of node-gyp via environment variable

I want to use custom node tarball to build node modules via node-gyp, is there any way to set it via environment variable or some config files for node-gyp or npm?

Read the entire recipe Recipe added 1 day ago