Tagged Questions
1267
votes
2answers
558k views
How do I get started with Node.js
Are there any good resources to get started with Node.JS? Any good tutorials, blogs or books?
Of course, I have visited its official website http://nodejs.org/, but I didn't think the documentation ...
1113
votes
12answers
127k views
How to decide when to use Node.js?
I am new to this kind of stuff, but lately I've been hearing a lot about how good Node.js is. Considering how much I love working with jQuery and JavaScript in general, I can't help but wonder how to ...
463
votes
16answers
145k views
How to debug node.js applications
How do I debug a node.js server application? Right now I'm mostly using alert debugging with print statements like this:
sys.puts(sys.inspect(someVariable));
There must be a better way to debug. I ...
433
votes
5answers
128k views
What is the purpose of Node.js module.exports and how do you use it?
What is the purpose of Node.js module.exports and how do you use it?
I can't seem to find any information on this, but it appears to be a rather important part of Node.js as I often see it in source ...
392
votes
9answers
145k views
How to pass command line arguments to node.js?
This is probably just a javascript question. I have a web server written in node that I would like to launch with a specific folder. I'm not sure how to access arguments in javascript. I'm running ...
274
votes
10answers
110k views
Can I use jQuery with Node.js?
Is it possible to use jQuery selectors/DOM manipulation on the server-side using Node.js?
227
votes
14answers
57k views
Node.js on multi-core machines
Node.js looks interesting, BUT I must miss something - isn't Node.js tuned only to run on a single process and thread?
Then how does it scale for multi-core CPUs and multi-CPU servers? After all, it ...
206
votes
22answers
89k views
Is there a template engine for Node.js? [closed]
I'm experimenting with building an entire web application using Node.js. Is there a template engine similar to (for example) the Django template engine or the like that at least allows you to extend ...
189
votes
4answers
139k views
Writing files in NodeJS
I've been trying to find a way to write to file when using NodeJS but with no success. Can you help me with this?
176
votes
3answers
5k views
Why does calling a function in the Node.js REPL with )( work?
Why is it possible to call function in JavaScript like this, tested with node.js:
~$ node
> function hi() { console.log("Hello, World!"); };
undefined
> hi
[Function: hi]
> hi()
Hello, ...
162
votes
14answers
66k views
Auto-reload of files in Node.js
EDIT: Use http://github.com/isaacs/node-supervisor; This is an old question and the code example is made with an outdated Node.js API.
Any ideas on how I could implement an auto-reload of files in ...
155
votes
8answers
38k views
module.exports vs exports in nodeJS
I've found the following contract in a node module:
module.exports = exports = nano = function database_module(cfg) {...}
I wonder whats the different between module.exports and exports and why ...
140
votes
6answers
19k views
How is Node.js inherently faster when it still relies on Threads internally?
I just watched the following video: Introduction to Node.js and still don't understand how you get the speed benefits.
Mainly, at one point Ryan Dahl (Node.js' creator) says that Node.js is ...
128
votes
3answers
81k views
Good beginners tutorial to socket.io? [closed]
I am very new to the world of webdevelopment and jumped into the bandwagon because I find the concept of HTML5 very interesting. I am fairly confident on working with canvas and would now like to move ...
124
votes
4answers
33k views
122
votes
8answers
103k views
how to get POST query in express node.js?
Here is my simple form:
<form id="loginformA" action="userlogin" method="post">
<div>
<label for="email">Email: </label>
<input type="text" ...
121
votes
7answers
86k views
How to use underscore.js as a template engine?
I'm trying to learn about new usages of javascript as a serverside language and as a functional language. Few days ago I heard about node.js and express framework. Then I saw about underscore.js as a ...
109
votes
8answers
50k views
Rails - Could not find a JavaScript runtime?
I created a new Rails project using rails 3.1.0.rc4 on my local machine but when I try to start the server I get:
Could not find a JavaScript runtime. See here for a list of available runtimes. ...
109
votes
8answers
35k views
Can I use CoffeeScript instead of JS for node.js?
What are my restrictions if I want to code node.js and use CoffeeScript?
Can I do anything I'd be able to do in JS?
107
votes
16answers
110k views
Render basic HTML view in Node JS Express?
I have a basic node js app that I am trying to get off the ground using Express framework. I have a Views folder where I have an "index.html" file. But I receive the following error when loading the ...
105
votes
9answers
56k views
In Node.js, how do I “include” functions from my other files?
Let's say I have a file called app.js. Pretty simple:
var express = require('express');
var app = express.createServer();
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
...
103
votes
13answers
21k views
How can I share code between Node.js and the browser?
I am creating a small application with a JavaScript client (run in the browser) and a Node.js server, communicating using WebSocket.
I would like to share code between the client and the server. I ...
102
votes
1answer
3k views
Why {} + {} is NaN only on the client side? Why not in Node.js?
While [] + [] is an empty string, [] + {} is "[object Object]", and {} + [] is 0. Why is {} + {} NaN?
> {} + {}
NaN
My question isn't why ({} + {}).toString() is "[object Object][object ...
100
votes
13answers
44k views
Read a file one line at a time in node.js?
Edit 2014: it seems the original answer is deprecated (read comments) apparently a transform stream http://strongloop.com/strongblog/practical-examples-of-the-new-node-js-streams-api/ is the new ...
93
votes
10answers
40k views
Node.js Unit Testing
Are there any good node.js (server side js) unit testing frameworks currently out there? I'm looking for something a little deeper than the Assert module provided.
91
votes
6answers
44k views
How to allow CORS in Express/NodeJS?
I am trying to support CORS in my NodeJS application that uses the Express JS web framework. I have read a Google group discussion about how to handle this, and read a few articles about how CORS ...
89
votes
6answers
69k views
getting all filenames in a directory with node.js
I can't find where in the documentation I can get all filenames in a directory.
89
votes
3answers
14k views
Node.js and CPU intensive requests
I've started tinkering with Node.js HTTP server and really like to write server side Javascript but something is keeping me from starting to use Node.js for my web application.
I understand the whole ...
86
votes
4answers
46k views
How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)
My version of node is always v0.6.1-pre even after I install brew node and NVM install v0.6.19.
My node version is:
node -v
v0.6.1-pre
NVM says this (after I install a version of node for the ...
82
votes
15answers
72k views
Good editor for Node.Js? [closed]
I am new to Node.js and server side JavaScript.
I plan to use Aptana Studio for editing. Is there any plugin I can install so that I can edit nodejs code on Aptana?
Are there any good IDEs ...
80
votes
7answers
38k views
Understanding promises in node.js
From what I have understood there are three ways of calling asynchronous code:
Events: eg. request.on("event"), callback);
Callbacks: eg. fs.open(path, flags, mode, callback);
Promises
I found a ...
78
votes
1answer
9k views
setImmediate vs. nextTick
Node.js version 0.10 was released today and introduced setImmediate. The Api changes documentation suggests using it when doing recursive nextTick calls.
From what mdn says it seems very similar to ...
78
votes
5answers
53k views
Javascript, NodeJS: is Array.forEach asynchronous?
I have a question regarding the native Array.forEach implementation of Javascript: Does it behave asynchronously?
For example, if I call:
[many many elements].forEach(function () {lots of work to ...
77
votes
18answers
19k views
How to avoid long nesting of asynchronous functions in Node.js
I want to make a page that displays some data from a DB, so I have created some functions that get that data from my DB. I'm just a newbie in Node.js, so as far as I understand, if I want to use all ...
77
votes
5answers
20k views
Getting-started: Setup Database for Node.js
I am new to node.js but am excited to try it out. I am using Express as a web framework, and Jade as a template engine. Both were easy to get setup following this tutorial from Node Camp.
However the ...
76
votes
1answer
21k views
Building a website using node.js - best practice [closed]
I was wondering how one would go about developing a website from scratch with node.js .
I understand how I could possibly do it, but I am interested in the best design practice.
I need this ...
75
votes
6answers
28k views
node.js require all files in a folder?
How do I require all files in a folder in node.js?
need something like:
files.forEach(function (v,k){
// require routes
require('./routes/'+v);
}};
71
votes
5answers
23k views
Open source service like Parse or Firebase? [closed]
Is there a open source / standalone / self hosted service like Parse or Firebase, preferably using Node.js. I really like the concept of a systems that manages data synchronization between all my apps ...
71
votes
4answers
14k views
Why and when to use Node.js? [duplicate]
Possible Duplicate:
How to decide when to use Node.js?
Sorry if I'm a bit ambiguous, but I'm trying to understand the real advantages of using Node.js instead of other server-side language.
...
70
votes
5answers
20k views
How to write a test which expects an Error to be thrown
I'm trying to write a test for the Jasmine Test Framework which expects an error. At the moment I'm using a jasmine nodejs integration from github.
In my nodejs module I have the following code:
...
70
votes
5answers
14k views
Coding Style Guide for node.js apps?
Is there a (or several) coding style guide for node.js? If not, what are the emerging styles used by the top open-source node projects?
I'm looking for a guide (or several guides) along the lines of ...
69
votes
3answers
14k views
How to get rid of Connect 3.0 deprecation alert?
I'm a node.js developer who creates web apps using express.js.
By now, my problem is:
Whenever I create an app on my computer, npm install its stuff and run it (with node app.js and nodemon) I get ...
68
votes
5answers
15k views
Javascript dependency management : npm vs bower vs volo?
How do you compare npm, bower and volo?
All three can be used to install javascript dependencies for a UI project.
I understand npm is more node specific.
So, when to use what?
npm still stands ...
68
votes
3answers
28k views
Node.js & Express.js: Breaking up the app.js file
Is there a common convention for breaking up and modularizing the app.js file in an Express.js application? Or is it common to keep everything in a single file?
65
votes
7answers
28k views
How to use redis PUBLISH/SUBSCRIBE with nodejs to notify clients when data values change?
I'm writing an event-driven publish/subscribe application with NodeJS and Redis. I need an example of how to notify web clients when the data values in Redis change.
65
votes
3answers
18k views
How does meteor work? [closed]
I came across meteor.js and while it seems exciting, I want to know how it works. I mean conventional web-apps work like this:
You have scripts on server which take data from database and add that ...
64
votes
6answers
37k views
Using npm to install or update required packages just like bundler for rubygems
I love Bundler, it's great at dependency management. I love npm, installing node packages is easy! I have a nodejs app and would love to be able to specify my apps dependencies and easily install / ...
63
votes
7answers
9k views
Can't get rid of header X-Powered-By:Express
I am running a server on nodejs with express. I can't seem to get rid of the header:
X-Powered-By:Express
I was wondering if there is any way to get rid of this header or do I have to live with it?
...
62
votes
8answers
20k views
Getting error while running simple javascript using node framework
As I run this piece of code using node a.js:
var sys = require('sys');
sys.puts('Hello, World');
I'm getting the following as an error
axconfig: port 1 not active
axconfig: port 2 not ...
62
votes
10answers
47k views
node.js execute system command synchronously
I need in node.js function
result = execSync('node -v');
that will synchronously execute the given command line and return all stdout'ed by that command text.
ps. Sync is wrong. I know. Just ...