Latest Node.js Recipes

Running a node.js app with upstart and Procfile

I have a node.js application.

I have written a Procfile with the following contents.

subscription-engine-processor: node index.js

Not sure whether i am doing it right, but i tried running it with the ruby gem foreman.

$ foreman start


Read the entire recipe Recipe added 6 minutes ago

Vows: command not found

I ran my tests from the root folder of my app. The tests lay within the spec directory.

$ vows  

No command 'vows' found, did you mean:
  Command 'vos' from package 'openafs-client' (universe)
  Command 'voms' from package 'voms-server'...

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

How do I pass a populated Mongoose object to the rendering code?

In the following code from my routes.js file, I can successfully populate some refs in a Mongoose object called Map. When I view the page, the console prints the fully populated version of popmap's editor objects.

  app.get('/map/:id', function(req,...

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

Adding a hook to globally log all node HTTP responses in node.js / express

I'm using node.js and express to handle HTTP requests and responses. By using the http.ServerRequest 'request' event, I can add a hook in and log HTTP requests. There doesn't seem to be a similiar event for http.ServerResponse and I am wondering how...

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

How to get socket client for a user?

I'm implementing a node.js server that manages bi-connections between users with (version:0.8.7). I use an array that stores the users that have no chat partners yet. When a user requests a new partner, the app picks a user in this array and...

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

Node.js - npm test <package> silently succeeded without any output?

npm test is a cool way to check the package. Output says 'npm is not ok' if package has some issue.

# npm test transkode

While if default test script passes it doesn't show any output. Can we enable the logs for test?

I did search in node.js...

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

Passing references to express-resources in node.js?

How can I pass for example the database reference

nano = require('nano')('')
db = nano.use('database')

to a resource 'User' (loaded with express-resource)?

I tried:

app.resource('user', require('./routes/user'), {db:...

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

Node.js response undefined when connected using http client

I am new to node.js and began by creating a small web app which runs at port 5000. When i tried this url which runs in my local(either via the browser or via curl), everything works fine, and i get back the response. But when i tried connecting it...

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

Node.js TCP incoming message splitting into packages

I have a problem when receiving large packets in Node.js through a TCP connection. It seems that there is a cap in the buffer set to about 55kB. When I receive large amounts of data (about 70-80k) it splits this data up.

Now, I've worked with UDP...

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

Module exporting with prototypes and export inheritance in node.js

I have some questions about module exporting and their inheritance in node.

I know you can export a module with

module.exports = function User(){
   // Lot of code

But, how could you add prototypes functions and get them exported as well? Is...

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

Can't connect to mongodb

I'm newbie about node.js and mongodb.

I have already installed mongodb, but I can't connect to mongodb.

This is my error:

Huys-MacBook-Pro:~ huy$ mongo
MongoDB shell version: 2.0.2
connecting to: test
Tue Jan  3 17:12:01 Error: couldn't connect to...

Read the entire recipe Recipe added 10 hours, 1 minute ago

Having a hard time trying to understand 'next/next()' in express.js

This is an example of it:

// Configuration
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');

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

Mongoose questions about routing and creating new objects

I am new to Node, and I'm using Mongoose as a driver for MongoDB. I'm using Jade for my views.

My "Edit" views and my "Show Object" views are looking great. However, I'm getting an "object is not defined" error when trying to create a new object....

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

parsing large xml 500M with node.js

I am using isaacs' SAX to parse a huge xml file. Also recommended by La Gentz.

The process uses about 650M of memory, how can I reduce this or allow node to use even more.

FATAL ERROR: CALL_AND_RETRY_0 Allocation failed - process out of memory


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

How do I generate CSRF tokens in Express?

newbie. I'm using ExpressJS/Node. Here's my config stuff:

var express = require('express'),
app = express.createServer(),
// Configuration
app.set('views', __dirname +...

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

Need recommendations for pattern for now.js object sharing in group

I have an application where I want to use node.js and now.js to share the state of an object within a nowjs "group" across any number of clients.

As an example of what I'm trying to do, let's say that within the multiroom chat example that comes with...

Read the entire recipe Recipe added 15 hours, 1 minute ago

Uncaught module jqueryify not found

My situation

I'm checking out spine.js for a web application I'm thinking of writing. I've read all the documentation and gone through all the examples. Now I'm trying to run the spine.contacts example project on my own Windows 7 laptop.

I'm running...

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

Node.js : How to enable non strict or ECMASCRIPT3 in V8 engine?

I believe V8 underlying Node.js supports strict mode or ES5 by default.

Can we enable non strict or ECMASCRIPT 3 in V8 engine?

almost 100% of ES5 features are available in Chrome (V8) see compatibility table .

But some developers(including me) are...

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

Tools to analyze core dump from Node.js

If I use gcore to make a code dump of a Node.js process, what are the best tools to analyze it?

Inspired by: Tool for analyzing java core dump

In my specific case, I'm interested in investigating some memory leaks, so I'm really curious to get some...

Read the entire recipe Recipe added 18 hours, 1 minute ago

Node.js callback confusion

I am trying to implement an autocompleter on a nodejs app using nowjs. = function(search) {  
  var response = getAutocomplete(search);

which calls:


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

Is it safe to use the node v8 options in a production environment?

node.js provides lower layer V8 options too. These options are very low layer like garbage collection or heap algo.

# node --v8-options

 --harmony_typeof (enable harmony semantics for typeof)
    type: bool  default: false

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

Heroku does not update node.js > package.json Github tarball dependecies

I am managing a dependency at Github which I use as a dependency in my project. I placed the dependecy as a tarball link (viz. into the package.json and it is working fine as expected locally. When...

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

Unable to load /nowjs/now.js

When I start the server, I get the following error

[Error: Unable to load shared library /home/boopathi/node_modules/now/node_modules/node-    proxy/lib/node-proxy.node]
Error: Unable to load shared library...

Read the entire recipe Recipe added 22 hours, 1 minute ago

How to pass variable from jade template file to a script file?

I'm having trouble with a variable (config) declared in a jade template file (index.jade) that isn't passed to a javascript file, which then makes my javascript crash. Here is the file (views/index.jade):


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

Can a proxy (like fiddler) be used with Node.js's ClientRequest

Can node.js be setup to recognize a proxy (like Fiddler for example) and route all ClientRequest's through the proxy?

I am using node on Windows and would like to debug the http requests much like I would using Fiddler for JavaScript in the...

Read the entire recipe Recipe added 1 day ago