473,482 questions
9
votes
2
answers
4k
views
Where are the CommonJS modules?
From time to time I hear that CommonJS http://www.commonjs.org/ is an effort to create a set of modular javascript components but frankly I have never understood anything of it.
Where are the these ...
1
vote
2
answers
161
views
Setting variable without callback
How is it possible that script continues even without proper setting variable? Thanks for reply!
Code
function get(param) {
// Connect to database and get the response ~ 1 sec
db.get(param, ...
1
vote
1
answer
5k
views
Node.js and undefined properties
I'm trying to use GET variables to transfer some simple data but for some reason I'm doing it wrong.
My code is pretty simple. I use Node.js HTTP & URL libraries. When I try to run following code,...
11
votes
5
answers
4k
views
Do i need Node.js in Python like I would with PHP?
I have been using PHP for some time now. And I have been thinking about learning Node.js to go along with it to use the non blocking idea for creating an online game or app. There is quite a bit of ...
1
vote
1
answer
3k
views
node.js and nginx SSL handshake failure
I'm trying to create a basic SSL connection from a node.js app to a locally hosted nginx server; it involves sending the client's credentials as well. The handshake seems like it was successful as ...
8
votes
6
answers
26k
views
Getting client hostname in Node.js
is it possible to get hostname in Node.js?
This is how I get client's IP:
var ip = request.header('x-forwarded-for');
So, how do I get client's hostname?
var hostname = request.header('???');
...
2
votes
2
answers
527
views
Long polling server principle (client identification)
I want to create a simple long polling server in node.js where communication will be based on jsonp requests. I understand that client makes request and server holds response until some data are ready ...
1
vote
4
answers
717
views
Should I re-write my game server, write a forwarder, or use a new plugin?
I have a game server written in python and twisted, and an old game client also in python. I have written a new game client in Javascript, which will connect with websockets. Now I face a design ...
0
votes
2
answers
280
views
User interacting interpreter in a non-blocking single-threaded environment (tricky)
For a school project me and a classmate are writing a domain-specific language in javascript (node). The language contains statements that require user input via a Websocket connection.
When a ...
10
votes
4
answers
3k
views
MongoDb vs CouchDb: write speeds for geographically remote clients
I would like all of my users to be able to read and write to the datastore very quickly. It seems like MongoDb has blazing reads, but the writes seem like they could be very very slow if the one ...
3
votes
3
answers
447
views
What are the differences between Opera Unite and Node.js?
Both seem to allow coding applications entirely in JavaScript. Both allow server side JS as well as client-side JS.
So, from a technology and programming standpoint, what is the difference between ...
0
votes
2
answers
544
views
Node.js core dumps on Windows 7
I am on windows 7 and installed Node.js using this tutorial:
http://howtonode.org/how-to-install-nodejs
When I am trying to run the tests , everything "CRASHES" (I don`t know why) and when I am ...
0
votes
2
answers
167
views
Is it possible to load the CSS stylesheets applied to a DOM in node.js?
This is a snippet of what I'm trying to do at the moment:
var sys = require("sys"),
request = require("request"),
$ = require("jquery"),
uri = 'http://' + process.argv[2];
...
0
votes
1
answer
789
views
How can you use selectors that match multiple nodes via jsdom/jquery in node.js?
I have a very simple example thus far, I'm basically trying to rip the path to a logo from a website dynamically.
var sys = require("sys"),
request = require("request"),
$ = require("jquery"),
...
164
votes
23
answers
64k
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 ...
2
votes
1
answer
1k
views
Node.js and SSL with Restler
I have installed latest version of Node.js and I still have problems with SSL and Restler. Where's the problem? Thank you!
Request
var restler = require('./lib/restler');
restler.get('https://...
2
votes
1
answer
3k
views
Install node.js on PowerVPS
I have one VPS from PowerVPS which has CentOS 5.5 (default configuration).
I need to install Node.JS for an Ajax IM installation.
Does anyone have any advice/information on how to install Node.JS on ...
185
votes
24
answers
121k
views
How to check whether a script is running under Node.js?
I have a script I am requiring from a Node.js script, which I want to keep JavaScript engine independent.
For example, I want to do exports.x = y; only if it’s running under Node.js. How can I ...
6
votes
5
answers
5k
views
V8 engine compiles JavaScript to machine code. So, why node.js isn't faster than C?
According to language benchmarks, JavaScript V8 is faster than other programming languages at regex-dna program. So, why node.js applications (i.e. http server) isn't faster than C applications (i.e. ...
6
votes
1
answer
6k
views
node.js concurrency
I'm new in node.js. I'm testing socket.io for real time messaging. I love it and I want to use. I have a question. How many concurrency can run in Node.js server ? Our program will be approximately ...
81
votes
7
answers
70k
views
Make node.js not exit on error
I am working on a websocket oriented node.js server using Socket.IO. I noticed a bug where certain browsers aren't following the correct connect procedure to the server, and the code isn't written to ...
8
votes
4
answers
5k
views
javascript - event driven and concurrency issues?
Greetings,
I've been studying javascript, nodejs. And I don't understand how the concurrency issues are avoided in javascript.
Lets say I'm working on a object
var bigObject = new BigObject();
...
3
votes
1
answer
2k
views
Using AMQP and Node.JS for realtime data syncing
I'm building a web-based productivity application that has to deal with modest user concurrency, and I've been exploring various options to keep the data in sync between the server and client. The ...
0
votes
1
answer
922
views
Read from file every time or load into array Node.js
I need to know if my idea is a good one.
Im putting together a web server that streams html file js file css file, kind of static web server.
As it been static i was thinking that i only need to ...
1
vote
1
answer
1k
views
direct (non-tcp) connection to redis from nodejs
hello all
I looked at the at the redis-node-client source (relevant part is shown bellow) and I see that it connects to redis via the 'net' package, which is TCP based.
line 370
exports....
10
votes
1
answer
20k
views
Parse XML Libxmljs (Node.js)
I'm attempting to parse an XML string with libxmljs (https://github.com/polotek/libxmljs). I'm having some issues though. I need to apply logic to what I'm parsing and return based upon what's defined ...
4
votes
1
answer
2k
views
Porting node.js server-side code to HTML5 WebSockets
Note: This is not about using both node.js and HTML5 sockets. I'm also not interested in discussing the merits of the setup I'm describing.
node.js runs on the server, and, since it supports ...
5
votes
3
answers
7k
views
PostgreSQL sockets from JavaScript (HTML5)
I'm looking at options to connect directly--without a web server or middleware--to a PostgreSQL server using JavaScript from a web browser client. On github, I found three projects:
node_postgres
...
5
votes
3
answers
3k
views
How to pause in the middle of a function (delay return) and continue on event
Is there a way to stop in the middle of a function, and wait for a certain event before continuing?
1
vote
3
answers
3k
views
node.js: Why does NODE_DEBUG=1 not work? (trying to debug a require() error)
I have a directory structure like so:
project
lib
paperboy
redis-client
node-cookie
srv
main.js
...
I start main.js from the project directory:
$ node srv/main.js
In main.js, ...
5
votes
3
answers
8k
views
Node.js copy remote file to server
Right now I'm using this script in PHP. I pass it the image and size (large/medium/small) and if it's on my server it returns the link, otherwise it copies it from a remote server then returns the ...
1
vote
2
answers
2k
views
javascript regex single-line
I'm trying to replace all @import strings in one single-string, e.g.
var str = 'buttons .reprint{height:56px;background-position:-47px -1496px;}@import "../common/buttons.css";@import "../screen/...
3
votes
3
answers
3k
views
.NET ServerVariables("AUTH_USER") and a non ASP page
I'm going to be running a node.js server in a Windows environment (via Cygwin) on an internal network that needs access to the Windows login information of the client. The best method I've come up ...
1
vote
0
answers
1k
views
nodejs and node-webworker
so this neat library is helping me with some things, but its acting strange with others.
I can see in its github repo history:
https://github.com/pgriess/node-webworker/commit/...
12
votes
5
answers
3k
views
Client Side Dependency Management in CoffeeScript
What is the best way to do Dependency Management amongst CoffeeScript files if the resulting javascript files eventually need to be concatenated together for use on the client side?
For server side ...
614
votes
12
answers
335k
views
How can I write a test which expects an 'Error' to be thrown in Jasmine?
I'm trying to write a test for the Jasmine Test Framework which expects an error. At the moment I'm using a Jasmine Node.js integration from GitHub.
In my Node.js module I have the following code:
...
58
votes
6
answers
70k
views
Global variables for node.js standard modules?
I know that global variables are bad.
But if I am using node's module "util" in 40 files in my framework, isn't it better to just declare it as a global variable like:
util = require('util');
in ...
0
votes
1
answer
802
views
Modifying 'global' object in Node.js
Is there any reason why the following code:
global.myNamespace = {};
fails to add 'myNamespace' to the global object, i.e.
typeof global.myNamespace
returns
'undefined'
Node.Js 0.3.1-pre
9
votes
4
answers
19k
views
'Global' object in node.js
I am using 0.3.1-pre Node.js
Doing this:
typeof global.parseInt
results in
'undefined'
However when pressing [Tab] in the console after typing 'global.' gives a list of functions, including ...
1
vote
2
answers
845
views
Chaining methods in Javascript
I want to chain methods in Javascript (using Node.js).
However, I encountered this error:
var User = {
'deletes': function() {
console.log('deletes');
return this;
},
'...
15
votes
2
answers
13k
views
Is anyone using node.js with an OAuth2.0 authentication system? [closed]
Is there an OAuth2.0 library for Node.js, which is being used (or planned to be used) in a live, production system?
49
votes
10
answers
21k
views
Does node.js support yield?
Is there any way to get generators into node.js?
I'm currently faking them with callbacks, but I have to remember to check the response of the callback inside of my generator function which creates a ...
5
votes
1
answer
2k
views
node.js + connect 404 error
I just started learning node.js. I have following (server) sample:
var app = require("express").createServer();
app.listen(80);
function fail(req, res, next) { setTimeout(next, 10); }
function ...
5
votes
2
answers
5k
views
Create chained methods in node.js?
Is it possible to create chained methods that are asynchronous like this in node.js
File.create('file.jpg').rename('renamed.jpg').append('Hello World')
That is to say non-blocking.
4
votes
2
answers
3k
views
RESTful MongoDB with Nodejs example needed
I'm trying to use MongoDB with REST interface on NodeJS express and I'm puzzled.
I've read about REST all day and I just cannot grasp it.
Let's say I have an untrusted (browser) client.
The untrusted ...
2
votes
2
answers
651
views
Can somebody help me understand node.js and how & why I might use it with a framework like rails?
I'm trying to write a scalable interactive chat application for an existing high traffic website. It needs to be scalable on day 1, and chat's concurrency and multi-broadcast issues make it a tricky ...
33
votes
3
answers
5k
views
JavaScript BDD: Vows & Kyuri Vs. Jasmine [closed]
I was going to go with Vows and Kyuri, but then I found out about Jasmine. Which do you recommend? Vows or Jasmine? Is there a Cucumber implementation that works with Jasmine?
292
votes
11
answers
273k
views
Sending emails in Node.js? [closed]
I recently started programming my first node.js. However, I discovered that I am unable to create a contact me form that sends straight to my email since I can't find any modules from node that is ...
0
votes
2
answers
1k
views
Injecting methods/variables into a Javascript scope
I want to be able to use methods that I haven't required() at the beginning of the file.
Something like this:
var contact = require('contact');
person = contact.create({
'name': createName()
});...
3
votes
2
answers
183
views
Method chaining in javascript
This working code is using Sproutcore:
person = SC.Object.create({
firstName: 'Foo',
lastName: 'Bar',
fullName: function() {
return this.get('firstName') + " " + this.get('...