1
vote
0answers
7 views

Nodejs cron plugin vs running nodejs script from crontab

I'm building a tool where users can enter a number of items they are interested in. Every 24 hours I want to run a script that checks certain JSON responses from external sources for these topics. My ...
0
votes
1answer
26 views

Cannot find module in Node.js

I have folowing directory structure: --app -- test -- server.js -- app.js I try to call function in app.js which exports from server.js, i do: var server = require("test/server"); But ...
0
votes
1answer
25 views

How to call a function when node server is up?

I want to call a function when the net.serverCreate is up. It need to call this function when the server is started and not when a new connection appears. Event 'listening' dont fire...When I start ...
0
votes
1answer
18 views

Syntax for a single function module targeting the browser and NodeJS

If I'm writing a JavaScript module for the browser, I'd assign it to window: window.myModule = function(){ }; For node, I'd assign it to module.exports: module.exports = function(){ }; What's ...
0
votes
1answer
36 views

use a typescript module/class in the browser and in the server (Node.Js)

How would I use the same typescript class or module in a client side javascript file and in a server side node.js file? I found a solution here where you manually create the exports variable instead ...
1
vote
0answers
16 views

Node-Webkit with external module containing native code

I'm using node-webkit with an external module called edge. According to the node-webkit docs modules that contain native code must be recompiled using nw-gyp as oppose to node-gyp. I was able to ...
0
votes
0answers
38 views

Using external nodejs modules in Node-Webkit

I'm trying to use the nodejs 'edge' module from within my node-webkit application. e.g. var edge = require('../node_modules/edge') var helloWorld = edge.func('async (input) => { return ".NET ...
0
votes
1answer
20 views

Using external modules within AppJs and nodejs

I've built a basic demo application using AppJS/NodeJS and edge. Heres the relevant part of the the app.js config file - Basically it just references the external modules. ....... window.on('ready', ...
0
votes
0answers
64 views

Underscore with nodejs and forever

I have a nodejs app and a module in a /lib folder that requires underscore. When I run nodejs, everything works fine but when I try to use forever with this command: NODE_ENV=production forever start ...
1
vote
1answer
35 views

How do I get the redirected url from the nodejs request module?

I'm trying to follow through on a url that redirects me to another page using the nodejs request module. Combing through the docs I could not find anything that allows me to retrieve the url after ...
1
vote
1answer
13 views

require().server. Require with a dot in the statement

var WebSocketServer = require('websocket').server; I came across this in some NodeJS code and I don't believe I have ever seen a require with a dot in the statement like this ever ...
0
votes
1answer
52 views

Access another module.exports function from the same file node.js

To make it a bit more clear to what I'm trying to achieve. I have a server running which includes many module, and one of the module use to check if the user role is an admin or not. in Server.js ...
0
votes
0answers
32 views

function call another function in Module.Exports Node.JS

I'm trying to make a function call inside my module but I'm getting functionTwo is not define. Module.js // Module.exports module.exports = function ( arg ) { if(arg instanceof Object) { ...
0
votes
3answers
43 views

Declare multiple module.exports in Node.js

What I'm trying to achieve is to create one module that contain with multiple function in it module.js module.exports = function(firstParam) { console.log("You did it"); }, module.exports = ...
1
vote
2answers
24 views

I can't receive data from custom module in node.js

I wrote a module called accountManager.js var sqlite3 = require('sqlite3'); var db = new sqlite3.Database("./users.db"); exports.userExists = function userExists(nickName) { var stmt = 'SELECT ...
2
votes
2answers
72 views

Relation between CommonJS, AMD and RequireJS?

I'm a lot confused about CommonJS, AMD and RequireJS. Even after reading a lot. I know that CommonJS (previously ServerJS) is a group for defining some JavaScript specifications (i.e. modules) when ...
0
votes
0answers
36 views

What node.js CSV modules support reading N records at a time?

I'm trying to read records from a large CSV file on demand. When the client requests the next chunk, the server must be able to read the next N records. Is there a CSV module that can do that? I've ...
1
vote
2answers
60 views

Order of resolution with nodejs require module

Suppose I have all of foo.js, foo.coffee, and foo.jsonin the same directory, and I say require './foo' from another (coffeescript) file in that location, what rule governs which one will be loaded? ...
2
votes
3answers
84 views

Node js globals within modules

In node I see variables initialized global inside modules are getting mixed up [changes done by one request affects the other] across requests. For Ex: a.js var a; function printName(req, res) { ...
2
votes
2answers
79 views

How do I choose a node module?

There are dozens of modules available out there, many fulfilling the same task. For instance, the list of router modules alone contains 26 modules. Given a list of modules, how can I pick the best ...
0
votes
0answers
90 views

Extend lodash/underscore on node.js?

Lodash and Underscore have a method called mixin that allow you to extend the libraries. How do you write a library that will extend them? For example, if you created a file called ...
0
votes
2answers
96 views

How do you pass objects around node express application?

I am building a node application using express and node-postgres (https://github.com/brianc/node-postgres). I only want to build the db client connection once, and I'd like to be able to access this ...
1
vote
2answers
51 views

Module system that works on Node.js and on the browser?

You are programming a lib X that depends on lib Y. You want that library to work on node.js and on the browser. On node.js, you'd use require('Y'). On the browser, you could use require.js. What's the ...
1
vote
1answer
87 views

Looking for node.js module which provide uniform file APIs for different storage providers

I use Node.js to host a web server. The server will communicate with different third party storage providers, such as Box, dropbox, googledrive, amazon s3, skydrive, ftp server, etc. The server will ...
0
votes
1answer
41 views

The Node Package Manager (NPM) seems to yield duplicated packages

I've been installing a few node packages and what I noticed is that NPM creates a bunch of duplicates. For example, I first installed mongoose, which installed a bunch of dependencies, naturally. ...
0
votes
1answer
43 views

Why can't I create a closure in nodejs a module

I'm trying to make the following nodejs module: exports.method = function () { var init = true; return function (args) { console.dir(args); }; }; But when I invoke this method I ...
0
votes
0answers
50 views

optimizing a module which requires other modules

I have the following project structure... built (folder) tools (folder) build.js curl.js r.js www (folder) page1.html js (folder) main.js module1.js module2.js and the following files... ...
0
votes
1answer
176 views

How in node.js send response with array of json objects?

I want to return array of finished pivotal stories using pivotal-node module for node.js. app.get('/delivered_stories', function(request, response) { pivotal.useToken("my_token"); ...
0
votes
1answer
96 views

How to remove module after “require” in node.js?

Let say, after I require a module and do something as below: var b = require('./b.js'); --- do something with b --- Then I want to take away module b (i.e. clean up the cache). how I can do it? ...
2
votes
2answers
49 views

Bundling node.js modules

I have these modules I'd like to import into my project: var ModuleA = require('./ModuleA.js'), ModuleB = require('./ModuleB.js'), ModuleC = require('./ModuleC.js'), ModuleD = ...
1
vote
1answer
58 views

Nodejs referencing module.exports

I'm trying to do some js code shared between the browser and the nodejs server. To do that, I just use these practises: http://caolanmcmahon.com/posts/writing_for_node_and_the_browser/ The problem is ...
0
votes
1answer
72 views

Cannot find module 'connect' on Mac OS X Lion

I installed connect module using NPM running the following command: npm install connect it created the module in /Download/usr/node_modules/connect folder. I created a file which uses connect ...
1
vote
1answer
75 views

Create a globally sccessible node.js module

I would like to create a globally accessible node.js module, like express and mocha. So I dived into their source code, and created the following short example: The index.js file, located in the ...
1
vote
0answers
362 views

Node.js spawn child process best practice

I need to spawn a mocha process. It can be installed either locally, or globally, I don't know in advance. This works only if mocha is installed globally: require("child_process").spawn("mocha", ...
0
votes
3answers
300 views

Node.js - check if module is installed without actually requiring it

I need to check whether "mocha" is installed, before running it. I came up with the following code: try { var mocha = require("mocha"); } catch(e) { console.error(e.message); ...
1
vote
1answer
99 views

Mojito - Load NodeJS Module

I'm using : Mojito 0.5.5 NPM 1.2.14 NodeJS 0.8.22 I'm trying to create a simple Mojito application using NodeJS modules, packaged with NPM. Documentation say that : Create a Mojito application. ...
1
vote
1answer
51 views

Can I simulate the bad internet situation like limit data transfer speed

I use node.js to develop app, I want simulate some bad internet situation when people surfer on the internet, like limit the data transfer speed, or delay some css or js file transfer How can I ...
-1
votes
1answer
46 views

Module is an empty object even after overriding module.exports

Here is some class in class.js: function Class(value1, value2) { this.value1 = value1; } Class.prototype = { value1: "default_value", method: function(argument) { this.value2 = argument + ...
1
vote
1answer
103 views

Refactoring a userscript to use javascript modules

I'm working on a userscript - in particular this userscript - which has been designed to encapsulate functionality in modules. In order to be able to do some automated testing I would like to split ...
0
votes
1answer
91 views

Node.js: recursive require and exports

Simply: How can I make a require() of a require (), and then get data back to original with an exports of an exports? Here is a practical example: My hello.js file: var text = "Hello world!" ...
0
votes
1answer
233 views

Custom module in nodejs returns “cannot find module” error

I've been writing a little prototype app in the cloud9 ide using express and nodejs. I was going to re-organize some code into a few custom modules but when I attempt to require them I get an error ...
0
votes
1answer
1k views

nodejs module.js:340 throw err; using WebSocket-Node

im new to this , i installed the nodejs with the installer in windows. then i installed the WebSocket-Node module with this command: npm install websocket , looks like successful install . npm http ...
3
votes
2answers
428 views

Why does this JavaScript code (module pattern for RequireJS and Node.js) work?

With my limited understanding of RequireJS and Node.js (plus JavaScript in general), I usually take a look at the source of some well-known JavaScript libraries. Every time I see something like this: ...
1
vote
1answer
80 views

node.js: Cannot find module 'it-is'

i'm trying to run this node.js unit tests and i get this error: module.js:340 throw err; ^ Error: Cannot find module 'it-is' from the code it's obvious that this 'it-is' module is a unit ...
0
votes
2answers
77 views

Cannot find function of undefined - CommonJS pattern

var revealed = function(){ var a = [1,2,3]; function abc(){ return (a[0]*a[1])+a[2]); } return { name: 'revealed', abcfn: abc } module.exports = revealed; }(); ...
0
votes
1answer
130 views

Directly call globally installed Node.js modules

Supposed I want to write a module for Node.js that shall be installed globally. I do not want to write any C++ (or something else), but plain Node.js code. Basically, this is very easy. Just write ...
1
vote
2answers
118 views

What is the best way to expose methods from Node.js?

Consider I want to expose a method called Print Binding method as prototype: File Saved as Printer.js var printerObj = function(isPrinted) { this.printed = isPrinted; } ...
4
votes
2answers
441 views

TypeScript 0.8.2 importing Node.js modules in internal modules

Okay, as I can see you would like to use internal modules in your project. Well, there was a workaround in TypeScript 0.8.1.1, you could define non exported module (internal) and add imports above it. ...
0
votes
2answers
119 views

Returning/getting object from a module in nodejs mongodb

I am working on a nodejs app. Folder structure is app app.js package.json ../model/schema.js ../controller/controller.js ../views All the logic is in controller.js while app.js performing routing ...
1
vote
1answer
258 views

module.export is not working CompoundJS?

I'm new to CompoundJS. I'm working on a sample app. If following the below tutorial: Using Mongoose Models I have written the below code in db/schema.js file: customSchema(function () { var ...

1 2 3 4
15 30 50 per page