Latest Node.js Recipes

How to make mocha watch, compile and test coffeescript with dependencies on save

I'm working on a project that uses coffeescript for development and testing. I run the tests in node with mocha's --watch flag on so I can have the tests run automatically when I make changes.

While this works to some extent, only the...

Read the entire recipe Recipe added 48 minutes ago

Can I write npm package in coffeescript?

I have used coffeescript for a while. Now I need to write a npm package, can I write it in coffeescript, or I should compile coffeescript into javascript?

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

GeddyJS & socket.io: catching and emitting events from server side

i would like to use socket.io along with Geddy. I just followed the instructions in the below link:

https://github.com/mde/geddy/wiki/Getting-started-with-Geddy,-Socket.io,-and-Authentication

Suggest me how to catch the 'connection' event on...

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

How to check if js code is running on node server or on the client

I want to determine whether my js code is running on the node server or on the client, and store it into a variable isServer = true if it is running on the server. How can I do that? Is there a way to simply check for the existence of a property that...

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

multiple gremlin commands combined as one

im using nodejs, neo4j with node-neo4j and trying to put multiple gremlin command together
and im stuck with this problem
if i execute the commands one after another like

x = [] as Set
y  = [] as...

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

Parse a date like 2012-11-07T00:00:00

I get from my client a date in this format:

2012-11-07T00:00:00 (yyyy-mm-ddT00:00:00)

How can I parse it into a Date object?

My first option is:

  • getting the first 10 characters (2012-11-07)
  • split that by "-"
  • creating new...

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

How to use Node.js nested Async forEachSeries loop

Using coffeescript to code One solution | see this post

I have two loops. I want to take each value from array 'a' and then loop through all the values of 'b' process them and move to next value in array 'a'

output expected:

1 a b c
2 a b c
3 a b...

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

Can I extend the iterator function in async.js forEach?

I am using async.js to run a for loop over a collection. For performance reasons, I want to pass in a database connection into the iterator method, so that it's not opening/closing a db connection each time the iterator runs. I am using mongoose.js...

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

Mongoose JS path default generating id

Take a look at the following schema:

var userSchema = new mongoose.Schema({
  fullName: {
    type: String,
    required: true,
    index: true
  },
  activationId: {
    type: mongoose.Schema.ObjectId
 ...

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

Call Download node app dependencies from another node application

i have a command tool application developed using node. when pointed over a folder when i run a command it should install the node dependencies specified in the package.json file in the folder. is it possible to do like this.

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

NodeJS Filesytem sync and performance

I've run into an issue with NodeJS where, due to some middleware, I need to directly return a value which requires knowing the last modified time of a file. Obviously the correct way would be to do

getFilename: function(filename, next) {
   ...

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

How to nest asynchronous functions based on array?

I have a async function that breaks it's callbacks into an object success and error, this function takes one param (besides the callback) "pink".

async("pink",{
    success:function(){

    },
    error:function(){

    }
});

I want to make plural...

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

node.js retrieve http csv file and load into mongoose

I'm very new to coding in general, so I apologize ahead of time if this question should be rather obvious. Here's what I'm looking to do, and following that I'll post the code I've used so far.

I'm trying to get gzip'd csv rank data from a website...

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

Unable to get Docpad to run on Windows

I'm having problems getting Docpad to run on Windows.

I did the following.

  • Installed the latest version of Node
  • "NPM Install Docpad"
  • Then typed "docpad run" in an empty directory

I got an error message that said 'docpad' is not recognized as an...

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

c++ software passing arguments method

I have a problem related to passing arguments to a C++ compiled executable. The program emulate the behaviour of a particular inference engine: the setup of the engine is load at runtime from an XML file, and then I want to call it from command line...

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

NodeJS plugin in IntelliJ Community Edition does not work

I have tried to use the NodeJS plugin in IntelliJ IDEA CE but can't get it to work. After the plugin have been installed and the IDE restarts, it says that it can't find Javascript plugin which is said to be required by NodeJS (though it doesn't say...

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

Redis + node.js render a list of objects

I'm experimenting with node.js and redis, and I managed to get a few functions to render single objects using Mustache as a template engine.

Now I'm a situation where I need to render items from a list, looking like this

list:$(id) = [node_id_1,...

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

Paypal IPN verification with node.js - express app

I am trying to implement Paypal IPN verification in my node.js app.I am using express framework.

This is my code :

app.post('/paypal', function(req,res){
console.log("IN PAYPAL !! req.body : "+req.body);
var ipn =...

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

Why does node.js path.resolve the empty string to the current working directory?

According to the docs, node.js's path.resolve function converts the passed argument to an absolute path. However, when I pass it the non-existent file '', it returns the current working directory:

~$ node -v
v0.8.14
~$ node
>...

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

Real time events when I click on div with node.js and socket.io

I´m making a simple real time application.

I have a page with a square and when I click the square is painted or remove the paint.

I want make the event in one tab and see his effect in other tab.

I dont have too much experience with node.js and...

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

Understanding freelist

https://github.com/joyent/node/blob/master/lib/freelist.js

Making a destroy method is very dangerous. I suggest that if you're concerned about this then you use require('freelist') and try to reclaim memory after using it - which is what I...

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

Shared Sessions between Node Apps?

I currently have two separate node apps running on two different ports but share the same backend data store. I need to share users sessions between the two apps so that when a user logs into through one app, their session is available and they...

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

Handle errors from EventEmitter

In class which inherits EventEmitter, we usually have two points to handle error.

someClass.on('error', function eventEmitterCallback(err){/* handle error*/});
//and
someClass.someAsyncAction(function asyncActionCallback(err){/* handle...

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

Node.js "FATAL ERROR: JS Allocation failed - process out of memory" -- possible to get a stack trace?

Well... I'm back to square one. I can't figure this out for the life of me.

I'm getting the following error:

FATAL ERROR: JS Allocation failed - process out of memory

I could enumerate the dozens (yes, dozens) of things I've tried to get to the...

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

Node.js and Parse.com for Dynamic Opengraph tags

I have a JS wep app & Parse.com backend which I would like to hook up to Facebook using Opengraph actions. Problem is being a web app, it's not possible to manipulate the meta tags in such a way so that the Facebook scraper will use it.

Most...

Read the entire recipe Recipe added 1 day ago