node.js

Node.JS Looking for an alternative to socket.IO

Hi, I've been testing Node.JS and Socket.IO for a couple of days. I'm interested in a real-time application that's why I'm testing Socket.IO, problem is I found many problems on several browsers. Chrome always works but IE and Firefox only some times. My question is, is there a way to push information from the server to the client with...

JSpec no longer supported?

Coming from the Ruby community I'm looking for a BDD-testing framework for Javascript/Node.js. I was JSpec and thought it would be the right choice because I used RSpec in Ruby. But on their GitHub page http://github.com/visionmedia/jspec it says it's no longer supported. They are abandoning this project? Does this mean I shouldn't u...

JavaScript Design Patterns -- Dealing With Unwanted Asynchrony

I'm pretty new to event-based programming (using node.js). I believe that there's something I'm just not grokking about it, because there's a particular problem that I keep coming across again and again and again. In short, that problem is dealing with asynchronicity when it seems to be getting in your way. This most often manifests it...

Share variables between modules in Javascript/node.js?

I have 3 node files: // run.js require('./configurations/modules'); require('./configurations/application'); // modules.js var express = module.exports.express = require('express'); var app = module.exports.app = express.createServer(); // app.js app.configure(...) Run.js requires both files, modules.js which require a module and...

What IDE to use for Node.js / Javascript?

What is your preference when it comes to editing/debugging large JavaScript projects, containing number of relatively big JS files? Please list your choice, why do you like it compared to others; If it is already listed you can up vote it if you like. ...

Recommended books for learning DTrace

Since the last question similar to this one is from 2008, I thought I'd ask it anyway to see what's new since then. I'm looking for books or other resources (though I prefer epubs for reading them on the go) for learning how to use DTrace, preferably but not necessarily for Cocoa, ruby or node.js development. ...

Global variables between files in Node.js?

Here are 2 files: // main.js require('./modules'); console.log(name); // prints "foobar" // module.js name = "foobar"; When I don't have "var" it works. But when I have: // module.js var name = "foobar"; name will be undefined in main.js. I have heard that global variables are bad and you better use "var" before the references. B...

MongoDB console javascript can't be used in application?

At the MongoDB developer zone you can learn all the MongoDB console javascript API to use for document CRUD operations. I wonder, do all these javascript functions only work on the MongoDB console? I learn all that just to use it for administrative tasks or can I use them in my javascript application (node) as well? ...

Is it possible to develop a Google App Engine web app using Node.js or some other server side JavaScript approach?

I've been following the latest developments with server-side JavaScript - especially Node.js - and wondering if there is any possibility of using such an approach to develop a Google App Engine web application - either separately from or in combination with Python or Java? ...

Javascript OOP library for client and server-side js (node.js)

Hi, is there any Javascript OOP library to easily work with classes, inherence and the like in a more class-based way to avoid prototypical OOP that works with JS both on the client (browser) and on the server (in my case Node.js, but generally that uses javascript core functions, so that can be used no matter the interpreter)? Thanks....

How to create appending writeStream in Node.js

Current documentation here doesn't seem to mention any parameters governing the stream's behaviour with regards to whether file is re-created every time or just gets data appended. Is there a way to create a writeStream which appends the data? ...

Is this a mal-formed http request from an iPad, which kills Node.js multipart parser

The below code is used in an iPad app to send an HTTP request to a Node.js web server, which produces the following error, but works fine w/ a regular HTML+browser form. The server is Node.js + formidable which has a multipart parser that only dies on this line of code with this error: message: parser error, 0 of 29162 bytes pars...

Nodejs - Stream output to broswer

var http = require("http"); var sys = require('sys') var filename = process.ARGV[2]; var exec = require('child_process').exec; var com = exec('uptime'); http.createServer(function(req,res){ res.writeHead(200,{"Content-Type": "text/plain"}); com.on("output", function (data) { res.write(data, encoding='utf8'); }); }).listen(8...

Nodejs web server calling requestListener twice when page is loaded

Hey guys, I am trying out node.js, the following is the example web server from the documentation with an added counter and it prints the counter to the console when ever a client/browser requests the page. The problem is, its being called twice when requested by the browser. This is what I would expect would happen: browser : Hello...

Ask element for their events

In javascript, is there a way yo as a element for the events that i can use to add listener. Something like: element = document.getElementById(id); console.log(element.listEvents); Im using a DOM example, but this would be usefull in node.js also. ...

What is the layout `yield` method in ejs?

I'm just starting with node.js + express + ejs. I can't find anywhere how to pull in the requested ejs file to the layout file. I know full well that yield is not the right thing here. e.g. layout.ejs <html> <head><title>EJS Layout</title></head> <body> <%= yield %> </body> </html> index.ejs <p>Hi</p> ...

Reinstall Node.js

What's the best way to reinstall node.js? ...

Deploying updates to production node.js code

Hi, This may be a basic question, but how do I go about effeciently deploying updates to currently running node.js code? I'm coming from a PHP, JavaScript (client-side) background, where I can just overwrite files when they need updating and the changes are instantly available on the produciton site. But in node.js I (obviously?) have...

Detecting close of client connect in node.js

I am using node.js for long held connections. I want to know how I can detect when the client connection closes (maybe when the user closes the tab). How do I specify a callback for that? ...

Streaming audio from a Node.js server to HTML5 <audio> tag

Hi everyone, I've been experimenting with binary streams in Node.js, and much to my amazement do actually have a working demo of taking a Shoutcast stream using node-radio-stream and pushing it into a HTML5 element using chunked encoding. But it only works in Safari! Here is my server code: var radio = require("radio-stream"); var ht...