Latest Node.js Recipes

Nodejs and a few more basic questions

After a few weeks trying to explore Nodejs and its basic tutorials on the internet, I'm no more than just a Nodejs User. As I start to get into real self-program server, I encounter several problems which I tried to Google but no resources seemed to...

Read the entire recipe Recipe added 17 minutes ago

Azure Deployment error with libxmljs for node.js

as the title suggests, I am trying to deploy my website on windows Azure that uses libsmljs, built on node.js of course. While Azure is deploying the site, it fails and spits this out:

Command:...

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

Node.js proxy through Apache on Amazon EC2

I'm trying to set up a proxy for my Node.js server on my EC2 instance, so I can access it through something like http://*.amazonaws.com/node, where * is the rest of the URI. I've set up the proxy by editing /etc/httpd/conf/httpd.conf with the...

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

mongoose objectid to number

How can I cast an ObjectId to a number? In my app I'm using the latest mongoose version and backbone on the clientside.

My problem is that the ObjectId always ends up being put in between quotes which results in double quotes like ""233453452534"" in...

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

mocha fs.existsSync always failing

I am attempting to check if a file exists in my mocha test. I know for a fact that the file exists in the test folder(I am placing it there for simplicity while I try and get this to work). But no matter what I do, fs.existsSync always fails....

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

Mocha Monitor Application Output

I'm building a logging module for my web app in nodejs. I'd like to be able to test using mocha that my module outputs the correct messages to the terminal. I have been looking around but haven't found any obvious solutions to check this. I have found...

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

TypeError: Cannot read property '_id' of undefined

Hello Gurus of Node + mongodb,

I am getting error "TypeError: Cannot read property '_id' of undefined" on a simple post request to save a document to the coolection books, My payload looks like this

{
    "name": "practical view",
    "author":...

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

Javascript - Parse Polynomials From String

I Just Asked this question for objective-c here, but need the answer quick and am able to do the parsing in either objective-c or javascript, so I will ask for js here.

In my app the user will be inputting a mathematical expression as a string, such...

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

Requested Node Engine Version Rejected by Heroku / Git

I'm following this basic tutorial to set up my node.js app on Heroku. when I do $ git push heroku master, the terminal responds with this answer:

----- Resolving engine versions ! Requested engine node version 0.10.17 does not match available...

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

Node + Express .post route throwing error. Expected callback, got object

I'm currently working on an app using Express + Node. I recently added a new .post route to the app.js file, using the following syntax:

app.post('/api/posts/saveComment', posts.saveComment);

posts is defined above as:

var posts =...

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

How can I create a new database in mongodb after dropping it?

In my end to end tests, I want to drop the "test" database, and then create a new test db. Dropping an entire database is simple:

mongoose.connection.db.command( {dropDatabase:1}, function(err, result) {
    console.log(err);
   ...

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

Detect broken SSL or insecure content warning with Selenium, BrowserStack, & Node.js

I'm trying to setup some automated testing using Browserstack's Selenium and their Node.js driver. I want to check if the page is showing any insecure content warnings when accessing the URL via HTTPS.

Is there a way to detect that in Selenium? If...

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

Node.js Javascript program killed processing 34kb file

  var parseFile = function(filename, fieldMap) {
      var array = [];
      var f = fs.readFileSync(filename);

      array = f.toString().split('\n');

      array = array.map(splitLines);
      array = array.map(function(lineArray) {
          var...

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

Time requests in NodeJS/Express

What would be the best way to time all requests coming into my node app? Basically I want to get the current timestamp at the very beginning of the request and then again at the very end of the request, get the difference and log it. Recommendations...

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

How to use IcedCoffeeScript on ExpressJS application

the question is how can I use IcedCoffeeScript (http://maxtaco.github.io/coffee-script) on my web-application based on ExpressJS? Now I use vanilla CoffeeScript language in my application.

Thank you

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

How to register a url protocol handler in Node.js

I am developing a command line node module and would like to be able to launch it via links on a website.

I want to register a custom protocol my-module:// such that links would have the following format: my-module://action:some-action and clicking...

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

Are Expressjs req, res objects garbage collected after the request?

Are expressjs req, res objects garbage collected after the request goes through and res.send() is called ?

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

Is there a simple JS xhr library (for node.js) that uses Q promises for get/post actions?

I'm looking for a JavaScript library that sits on top of node.js's http abstraction but returns Q promises (https://github.com/kriskowal/q) for http.get() and http.post() actions.

Does such thing exist?

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

Why do we need, what advantages to use mongoose

I have just started up with mongodb and I recently gone through Mongoose, an ODM framework.

On the documentation, I couldn't find why we need to use Mongoose. One reason I can give is we can define application schema from Mongoose.

I am looking for...

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

How to make a loop execute with a callback value of a function within


I am trying to update couchdb multiple times, each time the _rev changes. So i need to wait till i get callback from firs update. But the Node.js Loop seems to be iterating before i am getting the callback. Here is my code

function upload(req, res,...

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

Node.js error trying to communicate via SSL to backend server

We operate a WebSocket server on Node.js 0.8.16, which very frequently receives telemetry messages from clients, which is routed to a backend server using regular HTTPS posts.

After a random period of time, we notice communication will fail to the...

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

Seeing unexpected "undefined" in strings served by Node JS

I just created a very simple web server with Node JS which asks for the name of a JSON file, then loops through it and serves up certain keys within it as a "formatted" text-file.

CODE:

var http = require('http'),
prompt =...

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

Did I set up my Node.js right?

I'm pretty new to Node.js and just started learning the basics but already seem to be stuck from the start ('Hello World' application). Would really appreciate your help.

I installed Node.js (version 0.10.17) on my laptop (Windows7 x64), using the...

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

Nodejitsu - Error: No default engine was specified and no extension was provided


I'm having a problem with Nodejitsu. My app runs perfectly when deployed locally but I've recently been introduced to nodejitsu and I've uploaded my app, database and everything. However, when I try to deploy my application, I keep getting "Internal...

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

Express to generate JSON

I am trying to pass a key value and generate a JSON response based on the key passed

Express Program

var express = require('express'),
    async = require('async'),
    http = require('http'),
    mysql = require('mysql');

var app =...

Read the entire recipe Recipe added 1 day ago